ethan15864

Hamster ball

Oct 5th, 2016
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. scale = 10
  2.  
  3. function weld(tab)
  4. local last = nil
  5. for i,v in pairs(tab) do
  6. if v:IsA("BasePart") then
  7. if last then
  8. local w = Instance.new("Weld",last)
  9. w.Part0 = w.Parent
  10. w.Part1 = v
  11. local pos = last.CFrame:toObjectSpace(v.CFrame)
  12. w.C0 = pos
  13. end
  14. last = v
  15. end
  16. end
  17. end
  18.  
  19. function makeball(pos)
  20. local model = Instance.new("Model",workspace)
  21. local rand = BrickColor.Random()
  22. for i=0,340,20 do
  23. wait()
  24. for z=-90,70,20 do
  25. local p = Instance.new("Part",model)
  26. p.formFactor = "Custom"
  27. p.BrickColor = rand
  28. p.Transparency = 0.5
  29. p.Size = Vector3.new(scale/5.5,scale/5.5,scale/140)
  30. p.Anchored = true
  31. p.TopSurface = 0
  32. p.BottomSurface = 0
  33. p.CFrame = CFrame.new(pos) * CFrame.Angles(math.rad(z),math.rad(i),0) * CFrame.new(0,0,-scale/2)
  34. p:breakJoints()
  35. end
  36. end
  37. weld(model:children())
  38. for i,v in pairs(model:children()) do v.Anchored = false end
  39. model:MakeJoints()
  40. end
  41.  
  42. for _,v in pairs(game.Players:GetChildren()) do
  43. if v.Character then
  44. makeball(v.Character.Torso.Position+Vector3.new(0,scale/2-2.5,0))
  45. end
  46. end
Add Comment
Please, Sign In to add comment