Fairy


SUBMITTED BY: Pamlau

DATE: March 8, 2017, 10:43 a.m.

FORMAT: Lua

SIZE: 28.5 kB

HITS: 207

  1. local plr = game:service'Players'.LocalPlayer
  2. local m = plr:GetMouse()
  3. local char = plr.Character
  4. local runservice = game:service'RunService'
  5. local modelScale = 1/5
  6. pcall(function() local a = script.Parent.FaerieScript if a ~= script then a:Destroy() end end)
  7. pcall(function() local a = char.Animate if a ~= script then a.Disabled = true a:Destroy() end end)
  8. script.Name = "FaerieScript"
  9. function weld(a,b,c,d)
  10. local w = Instance.new("Weld",a)
  11. w.Part0 = a
  12. w.Part1 = b
  13. w.C0 = c or CFrame.new()
  14. w.C1 = d or CFrame.new()
  15. return w
  16. end
  17. function lerp(a,b,c)
  18. return a+(b-a)*c
  19. end
  20. do -- Ignore my clerp stuff stolen from stravvy
  21. local function QuaternionFromCFrame(cf)
  22. local mx, my, mz, m00, m01, m02, m10, m11, m12, m20, m21, m22 = cf:components()
  23. local trace = m00 + m11 + m22
  24. if trace > 0 then
  25. local s = math.sqrt(1 + trace)
  26. local recip = 0.5/s
  27. return (m21-m12)*recip, (m02-m20)*recip, (m10-m01)*recip, s*0.5
  28. else
  29. local i = 0
  30. if m11 > m00 then
  31. i = 1
  32. end
  33. if m22 > (i == 0 and m00 or m11) then
  34. i = 2
  35. end
  36. if i == 0 then
  37. local s = math.sqrt(m00-m11-m22+1)
  38. local recip = 0.5/s
  39. return 0.5*s, (m10+m01)*recip, (m20+m02)*recip, (m21-m12)*recip
  40. elseif i == 1 then
  41. local s = math.sqrt(m11-m22-m00+1)
  42. local recip = 0.5/s
  43. return (m01+m10)*recip, 0.5*s, (m21+m12)*recip, (m02-m20)*recip
  44. elseif i == 2 then
  45. local s = math.sqrt(m22-m00-m11+1)
  46. local recip = 0.5/s return (m02+m20)*recip, (m12+m21)*recip, 0.5*s, (m10-m01)*recip
  47. end
  48. end
  49. end
  50. local function QuaternionToCFrame(px, py, pz, x, y, z, w)
  51. local xs, ys, zs = x + x, y + y, z + z
  52. local wx, wy, wz = w*xs, w*ys, w*zs
  53. local xx = x*xs
  54. local xy = x*ys
  55. local xz = x*zs
  56. local yy = y*ys
  57. local yz = y*zs
  58. local zz = z*zs
  59. return CFrame.new(px, py, pz,1-(yy+zz), xy - wz, xz + wy,xy + wz, 1-(xx+zz), yz - wx, xz - wy, yz + wx, 1-(xx+yy))
  60. end
  61. local function QuaternionSlerp(a, b, t)
  62. local cosTheta = a[1]*b[1] + a[2]*b[2] + a[3]*b[3] + a[4]*b[4]
  63. local startInterp, finishInterp;
  64. if cosTheta >= 0.0001 then
  65. if (1 - cosTheta) > 0.0001 then
  66. local theta = math.acos(cosTheta)
  67. local invSinTheta = 1/math.sin(theta)
  68. startInterp = math.sin((1-t)*theta)*invSinTheta
  69. finishInterp = math.sin(t*theta)*invSinTheta
  70. else
  71. startInterp = 1-t
  72. finishInterp = t
  73. end
  74. else
  75. if (1+cosTheta) > 0.0001 then
  76. local theta = math.acos(-cosTheta)
  77. local invSinTheta = 1/math.sin(theta)
  78. startInterp = math.sin((t-1)*theta)*invSinTheta
  79. finishInterp = math.sin(t*theta)*invSinTheta
  80. else
  81. startInterp = t-1
  82. finishInterp = t
  83. end
  84. end
  85. return a[1]*startInterp + b[1]*finishInterp, a[2]*startInterp + b[2]*finishInterp, a[3]*startInterp + b[3]*finishInterp, a[4]*startInterp + b[4]*finishInterp
  86. end
  87. function clerp(a,b,t)
  88. local qa = {QuaternionFromCFrame(a)}
  89. local qb = {QuaternionFromCFrame(b)}
  90. local ax, ay, az = a.x, a.y, a.z
  91. local bx, by, bz = b.x, b.y, b.z
  92. local _t = 1-t
  93. return QuaternionToCFrame(_t*ax + t*bx, _t*ay + t*by, _t*az + t*bz,QuaternionSlerp(qa, qb, t))
  94. end
  95. end
  96. for i,v in pairs(char:GetChildren()) do
  97. if v:IsA("Hat") or v:IsA("BodyColors") or v:IsA("Clothing") or v:IsA("ShirtGraphic") then
  98. v:Destroy()
  99. end
  100. end
  101. Instance.new("Hat",char)
  102. local root = char.HumanoidRootPart
  103. local tw = root.RootJoint
  104. local tor = char.Torso
  105. local hd = char.Head
  106. local hum = char.Humanoid
  107. hum.Health = 40
  108. hum.MaxHealth = 40
  109. hum.WalkSpeed = 12
  110. local rl,ll = char["Right Leg"],char["Left Leg"]
  111. local ra,la = char["Right Arm"],char["Left Arm"]
  112. local c0 = {
  113. rs = CFrame.new(1,.5,0),
  114. ls = CFrame.new(-1,.5,0),
  115. rh = CFrame.new(.5,-1,0),
  116. lh = CFrame.new(-.5,-1,0),
  117. nk = CFrame.new(0,1,0),
  118. tw = CFrame.new(0,0,0)*CFrame.Angles(0,0,0),
  119. }
  120. local c1 = {
  121. rs = CFrame.new(-.5,.5,0),
  122. ls = CFrame.new(.5,.5,0),
  123. rh = CFrame.new(0,1,0),
  124. lh = CFrame.new(0,1,0),
  125. nk = CFrame.new(0,-.5,0),
  126. tw = CFrame.new(0,0,0)*CFrame.Angles(0,0,0)
  127. }
  128. local rs = tor["Right Shoulder"]
  129. local ls = tor["Left Shoulder"]
  130. local rh = tor["Right Hip"]
  131. local lh = tor["Left Hip"]
  132. local nk = tor["Neck"]
  133. for i,v in pairs(tor:GetChildren()) do
  134. if v:IsA("Motor6D") then
  135. v.DesiredAngle = 0
  136. v.MaxVelocity = 0
  137. v.CurrentAngle = 0
  138. end
  139. end
  140. pcall(function() tor.roblox:Destroy() end)
  141. pcall(function() char.Faerie:Destroy() end)
  142. local model = Instance.new("Model",char)
  143. model.Name = "Faerie"
  144. local BasePart = Instance.new("Part")
  145. BasePart.CanCollide = false
  146. BasePart.Anchored = false
  147. BasePart.FormFactor = "Custom"
  148. BasePart.Locked = true
  149. BasePart.Size = Vector3.new()
  150. BasePart.TopSurface,BasePart.BottomSurface,BasePart.LeftSurface,BasePart.RightSurface,BasePart.FrontSurface,BasePart.BackSurface = 10,10,10,10,10,10
  151. BasePart:BreakJoints()
  152. function NP(par)
  153. local p = BasePart:Clone()
  154. p.Parent = par or model
  155. return p
  156. end
  157. local w1 = NP()
  158. w1.Transparency = .1
  159. local w1m = Instance.new("SpecialMesh",w1)
  160. w1m.MeshId = "rbxassetid://19367766"
  161. w1m.TextureId = "rbxassetid://9854798"
  162. w1m.Scale = Vector3.new(1.05, 1.05, 1.05)
  163. local w1 = weld(tor,w1,CFrame.new(-.1,0.55,1.6))
  164. local w2 = NP()
  165. w2.Transparency = .1
  166. local w2m = Instance.new("SpecialMesh",w2)
  167. w2m.MeshId = "rbxassetid://19367766"
  168. w2m.TextureId = "rbxassetid://9854798"
  169. w2m.Scale = Vector3.new(1.05, 1.05, 1.05)
  170. local w2 = weld(tor,w2,CFrame.new(.1,0.55,1.6))
  171. local h = NP()
  172. local hm = Instance.new("SpecialMesh",h)
  173. hm.MeshId = "rbxassetid://154820214"
  174. hm.TextureId = "rbxassetid://91740209"
  175. hm.Scale = Vector3.new(1, 1, 1)
  176. weld(hd,h,CFrame.new(0,0.2,0))
  177. for i,v in pairs(char:GetChildren()) do
  178. if v:IsA("BasePart") then
  179. v.Material = "SmoothPlastic"
  180. v.TopSurface,v.BottomSurface,v.FrontSurface,v.BackSurface,v.LeftSurface,v.RightSurface = 10,10,10,10,10,10
  181. end
  182. end
  183. do
  184. if modelScale ~= 1 then
  185. for i,v in pairs(c0) do
  186. c0[i] = (v-v.p) + v.p*modelScale
  187. end
  188. for i,v in pairs(c1) do
  189. c1[i] = (v-v.p) + v.p*modelScale
  190. end
  191. local Joints = {}
  192. local gtJoints,gtParts;
  193. local function gtCFrame(cf)
  194. return (cf-cf.p) + cf.p * modelScale
  195. end
  196. function gtJoints(p)
  197. for i,v in pairs(p:GetChildren()) do
  198. if v:IsA("JointInstance") then
  199. table.insert(Joints,{v,v.Part0,v.Part1})
  200. v.Part0 = nil
  201. v.Part1 = nil
  202. v.C0 = (v.C0-(v.C0.p)) + (v.C0.p * modelScale)
  203. v.C1 = (v.C1-(v.C1.p)) + (v.C1.p * modelScale)
  204. end
  205. gtJoints(v)
  206. end
  207. end
  208. function gtParts(p)
  209. for i,v in pairs(p:GetChildren()) do
  210. if v:IsA("BasePart") then
  211. pcall(function() v.FormFactor = "Custom" end)
  212. local oldz = v.Size
  213. local cf = tor.CFrame:toObjectSpace(v.CFrame)
  214. v.Size = v.Size * modelScale
  215. v.CFrame = tor.CFrame * gtCFrame(cf)
  216. local mesh = nil
  217. for i,t in pairs(v:GetChildren()) do
  218. if t:IsA("DataModelMesh") then
  219. mesh = t
  220. end
  221. end
  222. if mesh == nil and v:IsA("Part") and v.Shape == Enum.PartType.Ball then
  223. mesh = Instance.new("SpecialMesh",v)
  224. mesh.MeshType = Enum.MeshType.Sphere
  225. end
  226. if mesh == nil and ((v:IsA("Part") and v.Shape == Enum.PartType.Block) or v:IsA("Seat") or v:IsA("VehicleSeat")) then
  227. mesh = Instance.new("BlockMesh",v)
  228. end
  229. if mesh ~= nil then
  230. if mesh:IsA("SpecialMesh") and mesh.MeshType == Enum.MeshType.FileMesh then
  231. mesh.Scale = mesh.Scale * modelScale
  232. else
  233. mesh.Scale = mesh.Scale*(oldz*modelScale)/v.Size
  234. end
  235. end
  236. end
  237. gtParts(v)
  238. end
  239. end
  240. gtJoints(char)
  241. gtParts(char)
  242. for i,v in pairs(Joints) do
  243. v[1].Part0 = v[2]
  244. v[1].Part1 = v[3]
  245. end
  246. end
  247. end
  248. rs.C0,rs.C1 = c0.rs,c1.rs
  249. ls.C0,ls.C1 = c0.ls,c1.ls
  250. rh.C0,rh.C1 = c0.rh,c1.rh
  251. lh.C0,lh.C1 = c0.lh,c1.lh
  252. nk.C0,nk.C1 = c0.nk,c1.nk
  253. tw.C0,tw.C1 = c0.tw,c1.tw
  254. local w10,w20 = w1.C0,w2.C0
  255. local pl = tor:FindFirstChild("FairyLight") or Instance.new("PointLight",tor)
  256. pl.Name = "FairyLight"
  257. pl.Shadows = false
  258. pl.Range = 8
  259. pl.Brightness = 10
  260. local sparkles = tor:FindFirstChild("FairySparkles") or Instance.new("Sparkles",tor)
  261. sparkles.Name = "FairySparkles"
  262. local outfit = 0
  263. local outfitparts = {ra,la,rl,ll,tor}
  264. local outfits = {
  265. {{106705109},{106705077},{106703301},{106703213},{106705037}}
  266. }
  267. local mycolor = ll.BrickColor.Color
  268. local mycolor2 = ll.BrickColor.Color
  269. function setOutfit()
  270. local of = outfits[outfit]
  271. if of then
  272. for i,v in pairs(outfitparts) do
  273. local mesh = v:FindFirstChild("outfitMesh")
  274. local meshdata = outfits[outfit][i]
  275. if not mesh then
  276. mesh = Instance.new("SpecialMesh",v)
  277. mesh.Name = "outfitMesh"
  278. mesh.TextureId = "rbxassetid://9854798"
  279. end
  280. mesh.Scale =(meshdata[2] or Vector3.new(1,1,1)) * modelScale
  281. mesh.MeshId = "rbxassetid://"..meshdata[1]
  282. mesh.VertexColor = Vector3.new(mycolor2.r,mycolor2.g,mycolor2.b)
  283. end
  284. else
  285. for i,v in pairs(outfitparts) do
  286. pcall(function() v.outfitMesh:Destroy() end)
  287. end
  288. end
  289. end
  290. setOutfit()
  291. local senabled = true
  292. local lenabled = true
  293. function changeColor()
  294. for i,v in pairs(char:GetChildren()) do
  295. if v:IsA("BasePart") then
  296. v.BrickColor = BrickColor.new(mycolor)
  297. end
  298. end
  299. local mc1 = Vector3.new(mycolor.r,mycolor.g,mycolor.b)
  300. local mc2 = Vector3.new(mycolor2.r,mycolor2.g,mycolor2.b)
  301. w1m.VertexColor,w2m.VertexColor,hm.VertexColor = mc1,mc1,mc2
  302. for i,v in pairs(outfitparts) do
  303. local mesh = v:FindFirstChild("outfitMesh")
  304. if mesh then
  305. mesh.VertexColor = mc2
  306. end
  307. end
  308. pl.Color = mycolor
  309. sparkles.SparkleColor = mycolor
  310. end
  311. changeColor()
  312. do
  313. pcall(function() plr.PlayerGui.fairyColoring:Destroy() end)
  314. local scr = Instance.new("ScreenGui",plr.PlayerGui)
  315. scr.Name = "fairyColoring"
  316. local fr = Instance.new("Frame",scr)
  317. fr.Size = UDim2.new(0,-150,0,-65)
  318. fr.BackgroundColor3 = Color3.new(1,1,1)
  319. fr.BorderColor3 = Color3.new(.05,.05,.05)
  320. fr.BackgroundTransparency = .8
  321. fr.Position = UDim2.new(1,0,1,scr.Parent:FindFirstChild("PandaHelpNotify") and -20 or 0)
  322. fr.ZIndex = 9
  323. local am = 75
  324. local rval,gval,bval = mycolor.r,mycolor.g,mycolor.b
  325. local r = Instance.new("TextButton",fr)
  326. r.BackgroundTransparency = 1
  327. r.Size = UDim2.new(0,75,0,15)
  328. r.Position = UDim2.new(0,5,0,5)
  329. r.TextColor3 = Color3.new(1,1,1)
  330. r.TextStrokeTransparency = .4
  331. for i=1,am do
  332. local t = Instance.new("ImageLabel",r)
  333. t.BorderSizePixel = 0
  334. t.Size = UDim2.new(1/am,0,1,0)
  335. t.Position = UDim2.new((i-1)/am,0,0,0)
  336. t.Name = i
  337. t.ZIndex = 10
  338. end
  339. local rb = Instance.new("ImageLabel",r)
  340. rb.ZIndex = 10
  341. rb.Size = UDim2.new(0,2,1,-2)
  342. rb.BackgroundColor3 = Color3.new(0,0,0)
  343. rb.BackgroundTransparency = .5
  344. rb.BorderColor3 = Color3.new(.4,.4,.4)
  345. rb.Name = "b"
  346. local g = r:Clone()
  347. g.Parent = fr
  348. g.Position = UDim2.new(0,5,0,25)
  349. local b = r:Clone()
  350. b.Parent = fr
  351. b.Position = UDim2.new(0,5,0,45)
  352. r.ZIndex,g.ZIndex,b.ZIndex = 10,10,10
  353. local prev = Instance.new("TextButton",fr)
  354. prev.Size = UDim2.new(0,55,0,45)
  355. prev.Position = UDim2.new(0,90,0,5)
  356. prev.ZIndex = 10
  357. prev.BorderColor3 = Color3.new(.2,.2,.2)
  358. prev.TextColor3 = Color3.new(1,1,1)
  359. prev.TextStrokeTransparency = .4
  360. prev.TextYAlignment = "Bottom"
  361. prev.FontSize = "Size8"
  362. prev.TextWrapped = true
  363. local res = Instance.new("TextButton",fr)
  364. res.Size = UDim2.new(0,55,0,9)
  365. res.Position = UDim2.new(0,90,0,51)
  366. res.ZIndex = 10
  367. res.BorderColor3 = Color3.new(.2,.2,.2)
  368. res.BackgroundColor3 = Color3.new(.5,0,0)
  369. res.TextColor3 = Color3.new(1,1,1)
  370. res.Text = "reset"
  371. res.FontSize = "Size8"
  372. local mode = 0
  373. local function update(set)
  374. r.b.Position = UDim2.new(rval,-1,0,1)
  375. g.b.Position = UDim2.new(gval,-1,0,1)
  376. b.b.Position = UDim2.new(bval,-1,0,1)
  377. local col = Color3.new(rval,gval,bval)
  378. prev.BackgroundColor3 = mode == 1 and mycolor2 or mycolor
  379. prev.Text = ""
  380. r.Text = math.floor(rval*255+.5)
  381. g.Text = math.floor(gval*255+.5)
  382. b.Text = math.floor(bval*255+.5)
  383. for i,v in pairs(r:GetChildren()) do
  384. local n = tonumber(v.Name)
  385. if n then
  386. local sc = n/am
  387. v.BackgroundColor3 = Color3.new(sc,gval,bval)
  388. end
  389. end
  390. for i,v in pairs(g:GetChildren()) do
  391. local n = tonumber(v.Name)
  392. if n then
  393. local sc = n/am
  394. v.BackgroundColor3 = Color3.new(rval,sc,bval)
  395. end
  396. end
  397. for i,v in pairs(b:GetChildren()) do
  398. local n = tonumber(v.Name)
  399. if n then
  400. local sc = n/am
  401. v.BackgroundColor3 = Color3.new(rval,gval,sc)
  402. end
  403. end
  404. if set ~= false then
  405. if mode == 0 then
  406. mycolor = col
  407. end
  408. if mode == 1 then
  409. mycolor2 = col
  410. end
  411. changeColor()
  412. end
  413. end
  414. update()
  415. local rd,gd,bd = false,false,false
  416. r.MouseButton1Down:connect(function(x,y) rd = true rval = (x-r.AbsolutePosition.X)/r.AbsoluteSize.X update() end)
  417. r.MouseButton1Up:connect(function() rd = false end)
  418. r.MouseLeave:connect(function() rd = false end)
  419. r.MouseMoved:connect(function(x,y) if not rd then return end rval = (x-r.AbsolutePosition.X)/r.AbsoluteSize.X update() end)
  420. g.MouseButton1Down:connect(function(x,y) gd = true gval = (x-g.AbsolutePosition.X)/g.AbsoluteSize.X update() end)
  421. g.MouseButton1Up:connect(function() gd = false end)
  422. g.MouseLeave:connect(function() gd = false end)
  423. g.MouseMoved:connect(function(x,y) if not gd then return end gval = (x-g.AbsolutePosition.X)/g.AbsoluteSize.X update() end)
  424. b.MouseButton1Down:connect(function(x,y) bd = true bval = (x-b.AbsolutePosition.X)/b.AbsoluteSize.X update() end)
  425. b.MouseButton1Up:connect(function() bd = false end)
  426. b.MouseLeave:connect(function() bd = false end)
  427. b.MouseMoved:connect(function(x,y) if not bd then return end bval = (x-b.AbsolutePosition.X)/b.AbsoluteSize.X update() end)
  428. res.MouseButton1Click:connect(function()
  429. rval,gval,bval = themeColor.Color.r,themeColor.Color.g,themeColor.Color.b
  430. update()
  431. end)
  432. local modebtn = Instance.new("TextButton",fr)
  433. modebtn.Position = UDim2.new(1,-150,0,-15)
  434. modebtn.Size = UDim2.new(0,49,0,14)
  435. modebtn.BackgroundColor3 = Color3.new(1,1,0)
  436. modebtn.BackgroundTransparency = .6
  437. modebtn.TextScaled = true
  438. modebtn.Font = 4
  439. modebtn.TextColor3 = Color3.new(1,1,1)
  440. modebtn.TextStrokeTransparency = .7
  441. modebtn.Text = "Body"
  442. modebtn.MouseButton1Click:connect(function()
  443. mode = (mode+1)%2
  444. local col = mode == 1 and mycolor2 or mycolor
  445. rval,gval,bval = col.r,col.g,col.b
  446. modebtn.Text = mode == 0 and "Body" or "Clothes"
  447. update(false)
  448. end)
  449. local outfitbtn = Instance.new("TextButton",fr)
  450. outfitbtn.Position = UDim2.new(1,-150,0,-30)
  451. outfitbtn.Size = UDim2.new(0,49,0,14)
  452. outfitbtn.BackgroundColor3 = Color3.new(1,1,0)
  453. outfitbtn.BackgroundTransparency = .6
  454. outfitbtn.TextScaled = true
  455. outfitbtn.Font = 4
  456. outfitbtn.TextColor3 = Color3.new(1,1,1)
  457. outfitbtn.TextStrokeTransparency = .7
  458. outfitbtn.Text = "Outfit"
  459. outfitbtn.MouseButton1Click:connect(function()
  460. outfit = (outfit+1)%(#outfits+1)
  461. setOutfit()
  462. end)
  463. local sparklebtn = Instance.new("TextButton",fr)
  464. sparklebtn.Position = UDim2.new(1,-100,0,-15)
  465. sparklebtn.Size = UDim2.new(0,100,0,14)
  466. sparklebtn.BackgroundColor3 = Color3.new(0,1,0)
  467. sparklebtn.BackgroundTransparency = .6
  468. sparklebtn.TextScaled = true
  469. sparklebtn.Font = 4
  470. sparklebtn.TextColor3 = Color3.new(1,1,1)
  471. sparklebtn.TextStrokeTransparency = .7
  472. sparklebtn.Text = "Sparkles"
  473. sparklebtn.MouseButton1Click:connect(function()
  474. senabled = not senabled
  475. sparklebtn.BackgroundColor3 = senabled and Color3.new(0,1,0) or Color3.new(1,0,0)
  476. end)
  477. local lightbtn = Instance.new("TextButton",fr)
  478. lightbtn.Position = UDim2.new(1,-100,0,-30)
  479. lightbtn.Size = UDim2.new(0,100,0,14)
  480. lightbtn.BackgroundColor3 = Color3.new(0,1,0)
  481. lightbtn.BackgroundTransparency = .6
  482. lightbtn.TextScaled = true
  483. lightbtn.Font = 4
  484. lightbtn.TextColor3 = Color3.new(1,1,1)
  485. lightbtn.TextStrokeTransparency = .7
  486. lightbtn.Text = "Light"
  487. lightbtn.MouseButton1Click:connect(function()
  488. lenabled = not lenabled
  489. lightbtn.BackgroundColor3 = lenabled and Color3.new(0,1,0) or Color3.new(1,0,0)
  490. end)
  491. end
  492. local gyro = root:FindFirstChild("RootGyro") or Instance.new("BodyGyro",root)
  493. gyro.maxTorque = Vector3.new()
  494. gyro.Name = "RootGyro"
  495. local vel = root:FindFirstChild("RootVel") or Instance.new("BodyVelocity",root)
  496. vel.maxForce = Vector3.new()
  497. vel.Name = "RootVel"
  498. vel.P = 4000
  499. local flying = false
  500. local state = "idle"
  501. local kd = {}
  502. local humspd = 0
  503. local flyspeed = 0
  504. local flystop = 0
  505. local sitting = false
  506. local holding = false
  507. m.KeyDown:connect(function(k)
  508. local now = tick()
  509. kd[k] = now
  510. if k == " " and not flying then
  511. pcall(function() sitting:Destroy() end)
  512. sitting = nil
  513. state = "fly"
  514. flying = true
  515. flydir = (root.CFrame.lookVector*Vector3.new(1,0,1)).unit
  516. elseif k == " " and state == "fly" then
  517. flying = false
  518. state = "idle"
  519. flystop = tick()
  520. elseif k == "x" and m.Target and (root.Position-m.Hit.p).magnitude < 20*modelScale then
  521. local tar = m.Target
  522. local cf = tar.CFrame:toObjectSpace(m.Hit)
  523. local siz = tar.Size/2
  524. local cfr
  525. local rx,ry,rz = 0,0,0
  526. local lv = tar.CFrame:vectorToObjectSpace(root.CFrame.lookVector)
  527. if math.abs(cf.Y-siz.Y) < .03 then
  528. cfr = CFrame.new(cf.p + Vector3.new(0,3*modelScale,0)) * CFrame.Angles(0,math.atan2(-lv.X,-lv.Z),0)
  529. elseif math.abs(-cf.Y-siz.Y) < .03 then
  530. cfr = CFrame.new(cf.p - Vector3.new(0,3*modelScale,0)) * CFrame.Angles(0,math.atan2(-lv.X,-lv.Z),math.pi)
  531. elseif math.abs(cf.X-siz.X) < .03 then
  532. cfr = CFrame.new(cf.p + Vector3.new(3*modelScale,0,0)) * CFrame.Angles(0,0,-math.pi/2) * CFrame.Angles(0,math.atan2(-lv.X,-lv.Z),0)
  533. elseif math.abs(-cf.X-siz.X) < .03 then
  534. cfr = CFrame.new(cf.p - Vector3.new(3*modelScale,0,0)) * CFrame.Angles(0,0,math.pi/2) * CFrame.Angles(0,math.atan2(-lv.X,-lv.Z),0)
  535. elseif math.abs(cf.Z-siz.Z) < .03 then
  536. cfr = CFrame.new(cf.p + Vector3.new(0,0,3*modelScale)) * CFrame.Angles(math.pi/2,0,0) * CFrame.Angles(0,math.atan2(-lv.X,-lv.Z),0)
  537. elseif math.abs(-cf.Z-siz.Z) < .03 then
  538. cfr = CFrame.new(cf.p - Vector3.new(0,0,3*modelScale)) * CFrame.Angles(-math.pi/2,0,0) * CFrame.Angles(0,math.atan2(-lv.X,-lv.Z),0)
  539. end
  540. if cfr then
  541. pcall(function() sitting:Destroy() end)
  542. flying = false
  543. state = "sit"
  544. if m.Target.Anchored then
  545. sitting = {tar = tar, cf = cfr}
  546. else
  547. sitting = weld(tar,root,cfr)
  548. end
  549. end
  550. end
  551. end)
  552. m.KeyUp:connect(function(k)
  553. kd[k] = nil
  554. end)
  555. hum.Running:connect(function(spd)
  556. if state ~= "idle" and state ~= "walk" and state ~= "inair" then return end
  557. humspd = spd
  558. state = flying and "fly" or (spd < 1 and "idle" or "walk")
  559. end)
  560. hum.Climbing:connect(function(spd)
  561. if state ~= "idle" and state ~= "walk" and state ~= "inair" then return end
  562. humspd = spd
  563. state = flying and "fly" or (spd < 1 and "idle" or "walk")
  564. end)
  565. hum.Seated:connect(function(a)
  566. state = a and "sit" or humspd > 0 and "idle" or "walk"
  567. end)
  568. hum.Changed:connect(function()
  569. if hum.Jump then
  570. hum.Jump = false
  571. end
  572. end)
  573. hum.FreeFalling:connect(function()
  574. if state ~= "idle" and state ~= "walk" and state ~= "inair" then return end
  575. state = math.abs(tor.Velocity.Y) > 1 and "inair" or state
  576. end)
  577. hum.FallingDown:connect(function(a)
  578. if not a then return end
  579. state = "inair"
  580. end)
  581. while true do
  582. runservice.RenderStepped:wait()
  583. local cam = workspace.CurrentCamera
  584. local alpha = .2
  585. sparkles.Enabled = senabled and flying and tor.Velocity.magnitude > 3
  586. pl.Enabled = lenabled
  587. if state ~= "fly" then
  588. if type(sitting) == "table" then
  589. gyro.maxTorque = Vector3.new(1,1,1)*4e6
  590. vel.maxForce = Vector3.new(1,1,1)*4e5
  591. gyro.cframe = sitting.tar.CFrame * sitting.cf
  592. vel.velocity = (gyro.cframe.p-root.Position)*10
  593. else
  594. gyro.maxTorque,vel.maxForce = Vector3.new(),Vector3.new()
  595. end
  596. end
  597. if sitting then
  598. state = "sit"
  599. end
  600. tw.MaxVelocity,rh.MaxVelocity,lh.MaxVelocity,rs.MaxVelocity,ls.MaxVelocity,nk.MaxVelocity = 0,0,0,0,0,0
  601. tw.CurrentAngle,rh.CurrentAngle,lh.CurrentAngle,rs.CurrentAngle,ls.CurrentAngle,nk.CurrentAngle = 0,0,0,0,0,0
  602. local hasRobe = outfit == 1
  603. if state == "idle" then
  604. hum.PlatformStand = false
  605. local breathing = math.sin(tick()*2)
  606. local tilt = .02 + breathing*.03
  607. w1.C0 = clerp(w1.C0,w10*CFrame.Angles(0,-.01+breathing*.01,0),alpha)
  608. w2.C0 = clerp(w2.C0,w20*CFrame.Angles(0,.01-breathing*.01,0),alpha)
  609. tw.C0 = clerp(tw.C0,c0.tw*CFrame.Angles(tilt,0,0),alpha)
  610. rh.C0 = clerp(rh.C0,c0.rh*CFrame.Angles(-tilt,hasRobe and 0 or -.1,hasRobe and 0 or .06),alpha)
  611. lh.C0 = clerp(lh.C0,c0.lh*CFrame.Angles(-tilt,hasRobe and 0 or .1,hasRobe and 0 or -.06),alpha)
  612. rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(-tilt,0,.1),alpha)
  613. ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(-tilt,0,-.1),alpha)
  614. nk.C0 = clerp(nk.C0,c0.nk*CFrame.Angles(-tilt+breathing*.05-.03,0,0),alpha)
  615. elseif state == "inair" then
  616. hum.PlatformStand = false
  617. local wings = math.sin(tick()*80)
  618. w1.C0 = clerp(w1.C0,w10*CFrame.Angles(0,-.15+wings*.3,0),.6)
  619. w2.C0 = clerp(w2.C0,w20*CFrame.Angles(0,.15-wings*.3,0),.6)
  620. local alpha = .15
  621. local tilt = .05
  622. local wavey = math.sin(tick()*3)
  623. tw.C0 = clerp(tw.C0,c0.tw*CFrame.Angles(tilt,0,0),alpha)
  624. rh.C0 = clerp(rh.C0,c0.rh*CFrame.Angles(-tilt+wavey*.1,0,hasRobe and 0 or .02),alpha)
  625. lh.C0 = clerp(lh.C0,c0.lh*CFrame.Angles(-tilt-wavey*.1,0,hasRobe and 0 or -.02),alpha)
  626. rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(-tilt-wavey*.07,0,.01),alpha)
  627. ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(-tilt+wavey*.07,0,-.01),alpha)
  628. nk.C0 = clerp(nk.C0,c0.nk*CFrame.Angles(-tilt+.2,0,0),alpha)
  629. elseif state == "walk" then
  630. hum.PlatformStand = false
  631. local walking = math.sin(tick()*25)
  632. local breathing = math.sin(tick()*2)
  633. local tilt = -.03-breathing*.02+walking*.01
  634. alpha = .6
  635. w1.C0 = clerp(w1.C0,w10*CFrame.Angles(0,-.05+breathing*.01+walking*.05,0),alpha)
  636. w2.C0 = clerp(w2.C0,w20*CFrame.Angles(0,.05-breathing*.01+walking*.05,0),alpha)
  637. tw.C0 = clerp(tw.C0,c0.tw*CFrame.Angles(tilt,-walking*.08,0),alpha)
  638. rh.C0 = clerp(rh.C0,c0.rh*CFrame.Angles(-tilt+walking*.3,0,hasRobe and 0 or .02),alpha)
  639. lh.C0 = clerp(lh.C0,c0.lh*CFrame.Angles(-tilt-walking*.3,0,hasRobe and 0 or -.02),alpha)
  640. rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(-tilt+.05-walking*.25,0,.01),alpha)
  641. ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(-tilt+.05+walking*.25,0,-.01),alpha)
  642. nk.C0 = clerp(nk.C0,c0.nk*CFrame.Angles(-tilt+breathing*.04,walking*.07,0),alpha)
  643. elseif state == "sit" then
  644. hum.Sit = false
  645. hum.PlatformStand = true
  646. local breathing = math.sin(tick()*2)
  647. local upvec = root.CFrame:vectorToWorldSpace(Vector3.new(0,1,0))
  648. if upvec.Y > .4 then
  649. local tilt = -.55+breathing*.015
  650. w1.C0 = clerp(w1.C0,w10*CFrame.Angles(0,-.01+breathing*.01,0),alpha)
  651. w2.C0 = clerp(w2.C0,w20*CFrame.Angles(0,.01-breathing*.01,0),alpha)
  652. tw.C0 = clerp(tw.C0,c0.tw*CFrame.Angles(tilt,0,0)+Vector3.new(0,-1.7,0)*modelScale,alpha)
  653. rh.C0 = clerp(rh.C0,c0.rh*CFrame.Angles(-tilt+1.57,0,hasRobe and 0 or .6),alpha)
  654. lh.C0 = clerp(lh.C0,c0.lh*CFrame.Angles(-tilt+1.57,0,hasRobe and 0 or -.6),alpha)
  655. rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(-tilt+.3,0,-.1)*CFrame.Angles(hasRobe and .3 or 0,hasRobe and .2 or 0,hasRobe and -.2 or 0)+(hasRobe and 0 or 1)*Vector3.new(-.85,-.25,-.25)*modelScale,alpha)
  656. ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(-tilt+.3,0,.1)*CFrame.Angles(hasRobe and .3 or 0,hasRobe and -.2 or 0,hasRobe and .2 or 0)+(hasRobe and 0 or 1)*Vector3.new(.85,-.25,-.25)*modelScale,alpha)
  657. nk.C0 = clerp(nk.C0,c0.nk*CFrame.Angles(-tilt+breathing*.04-.03,0,math.sin(tick()*4)*.06),alpha)
  658. else -- wallhug
  659. local breathing = math.sin(tick()*5)
  660. local tilt = -1.55+breathing*.015
  661. w1.C0 = clerp(w1.C0,w10*CFrame.Angles(0,-.01+breathing*.01,0),alpha)
  662. w2.C0 = clerp(w2.C0,w20*CFrame.Angles(0,.01-breathing*.01,0),alpha)
  663. tw.C0 = clerp(tw.C0,c0.tw*CFrame.Angles(tilt,0,0)+Vector3.new(0,-2.5,0)*modelScale,alpha)
  664. rh.C0 = clerp(rh.C0,c0.rh*CFrame.Angles(.2,0,hasRobe and 0 or .5)+Vector3.new(0,hasRobe and 0 or .2,0)*modelScale,alpha)
  665. lh.C0 = clerp(lh.C0,c0.lh*CFrame.Angles(.2,0,hasRobe and 0 or -.5)+Vector3.new(0,hasRobe and 0 or .2,0)*modelScale,alpha)
  666. rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(2.9,0,.8)+Vector3.new(-.2,.4,0)*modelScale,alpha)
  667. ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(2.9,0,-.8)+Vector3.new(.2,.4,0)*modelScale,alpha)
  668. nk.C0 = clerp(nk.C0,c0.nk*CFrame.Angles(breathing*.04+.7,0,0),alpha)
  669. end
  670. elseif state == "fly" then
  671. hum.PlatformStand = true
  672. gyro.maxTorque = Vector3.new(1,1,1)*4e6
  673. vel.maxForce = Vector3.new(1,1,1)*4e5
  674. local velocity = Vector3.new((kd.d and 1 or 0)+(kd.a and -1 or 0),0,(kd.s and 1 or 0)+(kd.w and -1 or 0))
  675. velocity = cam.CoordinateFrame:vectorToWorldSpace(velocity)
  676. local maxspeed = 40-(velocity.magnitude > 0 and velocity.unit.Y*20 or 0)
  677. if velocity.magnitude > 0 then
  678. flyspeed = lerp(flyspeed,maxspeed,.1)
  679. flydir = flydir:Lerp(velocity.unit,.4).unit
  680. hoverheight = nil
  681. else
  682. flyspeed = lerp(flyspeed,0,.3)
  683. flydir = (flydir*Vector3.new(1,0,1)).unit
  684. hoverheight = hoverheight or root.Position.Y
  685. end
  686. vel.velocity = flydir.unit * flyspeed
  687. if hoverheight then
  688. vel.velocity = vel.velocity + Vector3.new(0,hoverheight-root.Position.Y,0)
  689. end
  690. gyro.cframe = CFrame.new(Vector3.new(),flydir*Vector3.new(1,0,1))
  691. rl.CanCollide,ll.CanCollide = true,true
  692. local wings = math.sin(tick()*80)
  693. w1.C0 = clerp(w1.C0,w10*CFrame.Angles(0,-.15+wings*.3,0),.6)
  694. w2.C0 = clerp(w2.C0,w20*CFrame.Angles(0,.15-wings*.3,0),.6)
  695. local alpha = .15
  696. local flytilt = (flyspeed/maxspeed)
  697. local tilt = flytilt*-1.4 + math.asin(gyro.cframe:vectorToObjectSpace(flydir).unit.Y)
  698. local wavey = math.sin(tick()*6)
  699. tw.C0 = clerp(tw.C0,c0.tw*CFrame.Angles(tilt,0,0),alpha)
  700. rh.C0 = clerp(rh.C0,c0.rh*CFrame.Angles(wavey*.1,hasRobe and 0 or -.08,hasRobe and 0 or .1),alpha)
  701. lh.C0 = clerp(lh.C0,c0.lh*CFrame.Angles(-wavey*.1,hasRobe and 0 or .08,hasRobe and 0 or -.1),alpha)
  702. rs.C0 = clerp(rs.C0,c0.rs*CFrame.Angles(-wavey*.15,-.08,.1),alpha)
  703. ls.C0 = clerp(ls.C0,c0.ls*CFrame.Angles(wavey*.15,.08,-.1),alpha)
  704. nk.C0 = clerp(nk.C0,c0.nk*CFrame.Angles(-tilt*.8,0,0),alpha)
  705. end
  706. end

comments powered by Disqus