TheProNoob2004

Fairy

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