Demonlord27

fairy script

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