derekiscool423

rainbow tail

Dec 16th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1.  
  2.  
  3. local pl = game.Players.LocalPlayer
  4. local ch = pl.Character
  5. local tb = {}
  6.  
  7. local seg = 80
  8.  
  9. local a = Instance.new("Part", script)
  10. a.CanCollide = false
  11. a.Size = Vector3.new()
  12. a.Material = "Neon"
  13. local w = Instance.new("Weld",a)
  14. w.Part0 = ch.HumanoidRootPart
  15. w.Part1 = a
  16. w.C0 = CFrame.new(0,-1,.5)
  17.  
  18. local p = Instance.new("Part", script)
  19. p.Material = "Neon"
  20. p.Anchored = true
  21. p.CanCollide = false
  22. p.Size = Vector3.new()
  23. table.insert(tb,p)
  24.  
  25. for i = 1,seg-1 do
  26. local p = p:clone()
  27. p.Parent = script
  28. table.insert(tb,p)
  29. end
  30.  
  31. getRainbowRGB = function (tick)
  32. local section, secondary do
  33. section = tick % 1 * 3
  34. secondary = .5 * math.pi * (section % 1)
  35. if (section < 1) then
  36. return Color3.new (1, 1 - math.cos (secondary), 1 - math.sin (secondary))
  37. elseif (section < 2) then
  38. return Color3.new (1 - math.sin(secondary), 1, 1 - math.cos(secondary))
  39. else
  40. return Color3.new (1 - math.cos(secondary), 1 - math.sin(secondary), 1)
  41. end
  42. end
  43. end
  44.  
  45. t = 0
  46. while true do
  47. t = t + game:service"RunService".RenderStepped:wait()
  48. for i = 0,#tb-1 do
  49. local p1,p2 = tb[i],tb[i+1]
  50. if i==0 then p1 = a end
  51. local x = p1.Position.x - p2.Position.x
  52. local y = p1.Position.y - p2.Position.y
  53. local z = p1.Position.z - p2.Position.z
  54. local dist = math.sqrt(x^2+y^2+z^2)
  55. local diff = (p1.Size.z/(1/3) - dist)/dist
  56. x = x*.5*diff
  57. y = y*.5*diff
  58. z = z*.5*diff
  59. p2.Position = p2.Position - Vector3.new(x,y,z)
  60. p2.CFrame = CFrame.new((p1.Position+p2.Position)/2,p1.Position)
  61. p2.Color = getRainbowRGB(t + i/10)
  62. p1.Color = getRainbowRGB(t + i/10)
  63. end
  64. end
Add Comment
Please, Sign In to add comment