Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. local function Orbit(u,u2,d,s)
  2. local stepped = nil
  3. local an = 0
  4.  
  5. local g = Instance.new("BodyGyro", u.Torso)
  6. g.CFrame = CFrame.new(u.Torso.Position, u2.Torso.Position)
  7. g.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
  8.  
  9. local p = Instance.new("BodyPosition", u.Torso)
  10. p.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
  11. p.Position = u2.Torso.Position + Vector3.new(0,10,10)
  12.  
  13. local orbitSteppedFunc = function()
  14. local err,msg = pcall(function()
  15. g.CFrame = CFrame.new(u.Torso.Position, u2.Torso.Position)
  16. an = an + s
  17. local c = CFrame.new(u2.Torso.Position) --Start at the center of the circle
  18. * CFrame.Angles(0, math.rad(an), 0) --Rotate the brick
  19. * CFrame.new(0, 10, d)
  20.  
  21. p.Position = c.p
  22.  
  23. end)
  24. if err == false then
  25. stepped:disconnect()
  26. print(msg)
  27. end
  28. end
  29. stepped = game:GetService("RunService").Stepped:connect(orbitSteppedFunc)
  30. return stepped
  31. end
  32.  
  33. local function explode(d,p)
  34. local t, ll
  35. t={}
  36. ll=0
  37. if(#p == 1) then return {p} end
  38. while true do
  39. l=string.find(p,d,ll,true) -- find the next d in the string
  40. if l~=nil then -- if "not not" found then..
  41. table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
  42. ll=l+1 -- save just after where we found it for searching next time.
  43. else
  44. table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
  45. break -- Break at end, as it should be, according to the lua manual.
  46. end
  47. end
  48. return t
  49. end
  50.  
  51. local chat = game.Players.LocalPlayer.Chatted:connect(function(msg)
  52. if string.sub(msg, 0,5) == "orbit" then
  53. local st = explode(",", msg)
  54. Orbit(game.Workspace[st[2]],game.Workspace[st[3]],st[4],st[5])
  55. end
  56. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement