Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gravity = 0.01 -- earth gravity
- script.Name = "ORBYORB"..tostring(math.random(34,32764))
- local function AccurateWait(seconds)
- local RunService = game:GetService("RunService")
- if not seconds then
- seconds = 0
- end
- local last = tick()
- local secondsPassed = 0
- local connection = RunService.Heartbeat:Connect(function(dt)
- secondsPassed = secondsPassed + dt
- end)
- repeat
- RunService.Heartbeat:Wait()
- until secondsPassed >= seconds
- connection:Disconnect()
- end
- local function reverse_table(tab)
- local function deepCopy(original)
- local copy = {}
- for k, v in pairs(original) do
- if type(v) == "table" then
- v = deepCopy(v)
- end
- copy[k] = v
- end
- return copy
- end
- local t = deepCopy(tab)
- for i = 1, math.floor(#t/2) do
- local j = #t - i + 1
- t[i], t[j] = t[j], t[i]
- end
- return t
- end
- local function findParent(part)
- local tab = {}
- local current = part
- while current ~= game do
- table.insert(tab,tostring(current))
- current = current.Parent
- end
- tab = reverse_table(tab)
- local str = "game."
- for i,v in pairs(tab) do
- str = str..v.."."
- end
- return string.sub(str,1,#str-1)
- end
- local function addObject(pos,centerofgravityobj)
- coroutine.resume(coroutine.create(function()
- local remote = Instance.new("RemoteEvent",owner.Character)
- local part = Instance.new("Part",script)
- part.Name = "orb"..tostring(math.random(1,999999))
- part.CFrame = pos
- part.Anchored = true
- part.Size = Vector3.new(1,1,1)
- part.Shape = Enum.PartType.Ball
- part.Material = Enum.Material.Neon
- part.Color = Color3.new(math.random(),math.random(),math.random())
- wait()
- NLS([[
- local function AccurateWait(seconds)
- local RunService = game:GetService("RunService")
- if not seconds then
- seconds = 0
- end
- local last = tick()
- local secondsPassed = 0
- local connection = RunService.Heartbeat:Connect(function(dt)
- secondsPassed = secondsPassed + dt
- end)
- repeat
- RunService.Heartbeat:Wait()
- until secondsPassed >= seconds
- connection:Disconnect()
- end
- local p = ]]..findParent(part)..[[
- local part = p:Clone()
- part.Parent = p.Parent
- p:Destroy()
- local velocity = Vector2.new(0,0)
- local gravity = ]]..tostring(gravity)..[[
- while true do
- local op = ]]..findParent(centerofgravityobj)..[[.Position
- local pp = part.Position
- local mag = (op-pp).Magnitude
- local x = pp.X + (0-op.X)
- local z = pp.Z + (0-op.Z)
- local degree = math.deg(math.asin(x/mag))
- local xdirection = degree/90
- local zdirection = 1-math.abs(xdirection)
- if z < 0 then
- zdirection = zdirection * -1
- end
- velocity = Vector2.new(velocity.X+(xdirection*gravity),velocity.Y+(zdirection*gravity))
- part.Position = part.Position + Vector3.new(velocity.X*-1,0,velocity.Y*-1)
- script.Parent:FireServer(part.Position)
- AccurateWait()
- end]],remote)
- remote.OnServerEvent:Connect(function(plr,poss)
- if plr == owner then
- part.Position = poss
- end
- end)
- end))
- end
- --
- addObject(owner.Character.Head.CFrame * CFrame.new(0,0,0),owner.Character.HumanoidRootPart)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement