Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- repeat wait() until #game:GetService("Players"):GetPlayers() > 0
- local coms = {Instance.new("RemoteEvent",script),Instance.new("RemoteFunction",script),Instance.new("RemoteFunction",script)}
- local FF = Instance.new("ForceField",owner.Character)
- local waitremote = Instance.new('RemoteEvent',script)
- local conchar = nil
- FF.Visible = false
- local comsfuncs={
- function(plr, partname, partposition, partsize, partorientation)
- if plr ~= owner then
- return
- end
- if owner.Character.Parent then
- owner.Character.Parent = nil
- end
- if not conchar then
- conchar = Instance.new("Model",workspace)
- hum = Instance.new("Humanoid",conchar)
- hum.MaxHealth = 1
- return
- end
- if not conchar.Parent then
- conchar=nil
- return
- end
- if FF.Parent ~= owner.Character then
- FF = Instance.new("ForceField",owner.Character)
- FF.Visible = false
- end
- conchar.Name = "Ghost"
- local part = conchar:FindFirstChild(partname)
- if not part then
- pcall(function()
- part = Instance.new("Part",conchar)
- part.Size = partsize+Vector3.new(0.125,0.125,0.125)
- part.Name = partname
- if partname == "Head" then
- local headmesh = Instance.new("SpecialMesh",part)
- headmesh.Scale = Vector3.new(1.25,1.25,1.25)
- headmesh.MeshType = Enum.MeshType.Head
- end
- end)
- end
- if part then
- if partname == "HumanoidRootPart" then
- part.Transparency = 1
- else
- part.Transparency = 0.5
- end
- part.Name = partname
- part.Anchored = true
- part.Position = partposition
- part.Orientation = partorientation
- part.Color = Color3.new(0, 0, 0)
- end
- end,
- function(plr)
- if plr ~= owner then
- return
- end
- return conchar
- end,
- function(plr,t)
- if plr ~= owner then
- return
- end
- return t
- end
- }
- coms[1].Name = "Com1"
- coms[2].Name = "Com2"
- coms[3].Name = "Com3"
- waitremote.Name = "WaitRemote"
- coms[3].OnServerInvoke = comsfuncs[3]
- coms[2].OnServerInvoke = comsfuncs[2]
- coms[1].OnServerEvent:Connect(comsfuncs[1])
- NLS([==[
- local remote=script.Parent.Com1
- local com1 = script.Parent.Com2
- local com3 = script.Parent.Com3
- local ping = 0.01
- function predict(part)
- local Position = part.Position
- local Velocity = part.Velocity
- local futurePosition = Position + (Velocity * ping)
- return futurePosition
- end
- spawn(function()
- while wait(1) do
- local start_tick=tick()
- com3:InvokeServer()
- ping = tick() - start_tick
- end
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- if game:GetService("Players").LocalPlayer.Character.Parent ~= workspace then
- game:GetService("Players").LocalPlayer.Character.Parent = workspace
- end
- end)
- local parttable={}
- local FF
- local prediction = false
- game:GetService("Players").LocalPlayer.Chatted:Connect(function(msg)
- local args = msg:split(" ")
- if args[1] == "PositionPredict" then
- if args[2] then
- if args[2] == "enable" then
- prediction = true
- elseif args[2] == "disable" then
- prediction = false
- end
- else
- prediction = not prediction
- end
- end
- end)
- game:GetService("RunService").Stepped:Connect(function()
- coroutine.resume(coroutine.create(function()
- if com1:InvokeServer() then
- for _,part in pairs(com1:InvokeServer():GetDescendants()) do
- if part:IsA("BasePart") then
- part.CanCollide = false
- part.Velocity = Vector3.new(0,0,0)
- elseif part:IsA("Humanoid") then
- part:Destroy()
- end
- end
- end
- end))
- if not FF then
- FF = Instance.new("ForceField")
- end
- if not FF.Parent then
- FF = nil
- end
- if FF then
- FF.Visible = false
- end
- for _, part in pairs(game:GetService("Players").LocalPlayer.Character:GetChildren()) do
- coroutine.resume(coroutine.create(function()
- local part = part
- if part:IsA("BasePart") then
- if parttable[part.Name] ~= part.CFrame then
- parttable[part.Name] = part.CFrame
- --print("Firing")
- local Positionpart = part.Position
- if prediction then
- Positionpart = predict(part)
- end
- remote:FireServer(part.Name, Positionpart, part.Size, part.Orientation)
- end
- end
- end))
- end
- end)
- script.Parent.WaitRemote:FireServer()
- ]==],script)
- game:GetService("RunService").Heartbeat:Connect(function()
- for i=1,#coms do
- if not coms[i].Parent then
- local ClassName = coms[i].ClassName
- coms[i] = Instance.new(ClassName,script)
- if ClassName == "RemoteEvent" then
- coms[i].OnServerEvent:Connect(comsfuncs[i])
- elseif ClassName == "RemoteFunction" then
- coms[i].OnServerInvoke = comsfuncs[i]
- end
- end
- if coms[i].Name ~= "Com" .. tostring(i) then
- coms[i].Name = "Com" .. tostring(i)
- end
- end
- end)
- script.Parent = owner.PlayerGui
- print("waiting")
- waitremote.OnServerEvent:Wait()
- print("Destroy! wait remote")
- waitremote:Destroy()
- owner.Character.Parent = nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement