Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gravity = 0.1 -- earth gravity
- local friction = 1
- 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 center = nil
- local function addObject(pos,centerofgravityobj,usecenter)
- 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
- local num = math.random(5,50)/10
- part.Size = Vector3.new(num,num,num)
- part.Shape = Enum.PartType.Ball
- part.Material = Enum.Material.Neon
- part.Color = Color3.new(math.random(),math.random(),math.random())
- local atch1 = Instance.new("Attachment",part)
- atch1.Position = Vector3.new(0,part.Size.Y/2,0)
- local atch2 = Instance.new("Attachment",part)
- atch2.Position = Vector3.new(0,part.Size.Y/2*-1,0)
- local trail = Instance.new("Trail",part)
- trail.Attachment0 = atch1
- trail.Attachment1 = atch2
- trail.Color = ColorSequence.new(part.Color,part.Color)
- trail.Lifetime = 0.3
- trail.WidthScale = NumberSequence.new(3,0)
- trail.Texture = "http://www.roblox.com/asset/?id=5699911427"
- trail.LightEmission = 1
- trail.FaceCamera = true
- if usecenter then
- centerofgravityobj = center
- end
- 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.CanCollide = false
- part.Parent = p.Parent
- p:Destroy()
- local velocity = Vector2.new(0,0)
- local gravity = ]]..tostring(gravity)..[[
- local friction = ]]..tostring(friction)..[[
- while true do
- local op = ]]..findParent(centerofgravityobj)..[[.Position
- local pp = part.Position
- local mag = (op-pp).Magnitude
- local mass = ((mag*1)^-0.5)/0.25
- 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*friction)+(xdirection*gravity*mass),(velocity.Y*friction)+(zdirection*gravity*mass))
- 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