Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function Orbit(u,u2,d,s)
- local stepped = nil
- local an = 0
- local g = Instance.new("BodyGyro", u.Torso)
- g.CFrame = CFrame.new(u.Torso.Position, u2.Torso.Position)
- g.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
- local p = Instance.new("BodyPosition", u.Torso)
- p.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- p.Position = u2.Torso.Position + Vector3.new(0,10,10)
- local orbitSteppedFunc = function()
- local err,msg = pcall(function()
- g.CFrame = CFrame.new(u.Torso.Position, u2.Torso.Position)
- an = an + s
- local c = CFrame.new(u2.Torso.Position) --Start at the center of the circle
- * CFrame.Angles(0, math.rad(an), 0) --Rotate the brick
- * CFrame.new(0, 10, d)
- p.Position = c.p
- end)
- if err == false then
- stepped:disconnect()
- print(msg)
- end
- end
- stepped = game:GetService("RunService").Stepped:connect(orbitSteppedFunc)
- return stepped
- end
- local function explode(d,p)
- local t, ll
- t={}
- ll=0
- if(#p == 1) then return {p} end
- while true do
- l=string.find(p,d,ll,true) -- find the next d in the string
- if l~=nil then -- if "not not" found then..
- table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
- ll=l+1 -- save just after where we found it for searching next time.
- else
- table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
- break -- Break at end, as it should be, according to the lua manual.
- end
- end
- return t
- end
- local chat = game.Players.LocalPlayer.Chatted:connect(function(msg)
- if string.sub(msg, 0,5) == "orbit" then
- local st = explode(",", msg)
- Orbit(game.Workspace[st[2]],game.Workspace[st[3]],st[4],st[5])
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement