Advertisement
deadropz

cape

Apr 18th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. --dont worry about specials, i bypassed it(didnt remove this because i didnt want to screw up the script)
  2.  
  3. local specials = {"DaMrNelson", "Vividex", 3925445, "Player1"} -- String for username, number for userid
  4. local capeColor = BrickColor.new("White")
  5. local capeLength = 4.5
  6. local renderCap = 20000 -- Stop rendering capes for players over 200 studs away
  7.  
  8. local runServ = game:GetService("RunService")
  9.  
  10. function canUseCape(player) -- Edit to only return true if you want everyone to wear a cape
  11. return true
  12. end
  13.  
  14. function applyCape(char) -- Where all the magic happens
  15. if (game.Workspace.CurrentCamera.Capes:FindFirstChild("Cape" .. char.Name)) then
  16. game.Workspace.CurrentCamera.Capes["Cape" .. char.Name]:Destroy()
  17. end
  18.  
  19. while (char and not char.Parent and not char:FindFirstChild("Torso")) do
  20. runServ.Heartbeat:wait()
  21. end
  22.  
  23. if (not char or not char.Parent) then
  24. return "Uh oh!"
  25. end
  26.  
  27. local cape = Instance.new("Model", game.Workspace.CurrentCamera.Capes)
  28. cape.Name = "Cape" .. char.Name
  29.  
  30. local bits = {}
  31. local isShowing = true
  32.  
  33. for x = 1, 10 do
  34. if (not bits[x]) then
  35. bits[x] = {}
  36. end
  37.  
  38. for y = 1, capeLength / 0.2 do
  39. local p = Instance.new("Part", cape)
  40. p.FormFactor = "Custom"
  41. p.Size = Vector3.new(0.2, 0.2, 0.2)
  42. p.BrickColor = capeColor
  43. p.CanCollide = false
  44. p.Anchored = true
  45. p.Material="SmoothPlastic"
  46. p.TopSurface="SmoothNoOutlines"
  47. p.BottomSurface="SmoothNoOutlines"
  48. p.LeftSurface="SmoothNoOutlines"
  49. p.RightSurface="SmoothNoOutlines"
  50. p.FrontSurface="SmoothNoOutlines"
  51. p.BackSurface="SmoothNoOutlines"
  52.  
  53. bits[x][y] = p
  54. end
  55. end
  56.  
  57. Spawn(function() -- So noobs don't have to thread this themselves
  58. while (cape and cape.Parent and char and char:FindFirstChild("Torso") and char.Parent == game.Workspace) do
  59. if ((char:GetModelCFrame().p - game.Workspace.CurrentCamera.CoordinateFrame.p).magnitude <= 200) then
  60. if (not isShowing) then
  61. for x = 1, #bits do
  62. for y = 1, #bits[x] do
  63. bits[x][y].Transparency = 0
  64. end
  65. end
  66.  
  67. isShowing = true
  68. end
  69.  
  70. for x = 1, #bits do
  71. for y = 1, #bits[x] do
  72. local bit, lastPos = bits[x][y], bits[x][y].CFrame - Vector3.new(0, 0.2, 0)
  73. local bitTop = y > 1 and bits[x][y - 1] or nil
  74. local cf
  75.  
  76. if (bitTop) then
  77. local pos, lookAt = bitTop.CFrame * CFrame.new(0, 0, -0.1), lastPos.p
  78. cf = CFrame.new(pos.p, lookAt) * CFrame.new(0, 0, -0.1)
  79. else
  80. local pos, lookAt = char.Torso.CFrame * CFrame.new(0, 1.1, 0.6) * CFrame.new(x * 0.2 - 1.1, (-y + 1) * 0.2 - 0.1, 0), lastPos.p
  81. cf = CFrame.new(pos.p, lookAt) * CFrame.new(0, 0, -0.1)
  82. end
  83.  
  84. bit.CFrame = cf
  85. end
  86. end
  87. elseif (isShowing) then
  88. for x = 1, #bits do
  89. for y = 1, #bits[x] do
  90. bits[x][y].Transparency = 1
  91. end
  92. end
  93.  
  94. isShowing = false
  95. end
  96.  
  97. runServ.RenderStepped:wait()
  98. end
  99.  
  100. if (cape and cape.Parent) then
  101. cape:Destroy()
  102. end
  103. end)
  104. end
  105.  
  106. function playerAdded(player)
  107. --if (canUseCape(player)) then
  108. player.CharacterAdded:connect(function(char)
  109. applyCape(char)
  110. end)
  111.  
  112. if (player.Character and player.Character.Parent == game.Workspace) then
  113. applyCape(player.Character)
  114. end
  115. --end
  116. end
  117.  
  118. if (game.Workspace.CurrentCamera:FindFirstChild("Capes")) then
  119. game.Workspace.CurrentCamera.Capes:ClearAllChildren()
  120. else
  121. Instance.new("Model", game.Workspace.CurrentCamera).Name = "Capes"
  122. end
  123.  
  124. for i, player in pairs(game.Players:GetPlayers()) do
  125. playerAdded(player)
  126. end
  127.  
  128. game.Players.PlayerAdded:connect(playerAdded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement