Advertisement
plytalent

prototype ghost

Sep 22nd, 2021 (edited)
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. repeat wait() until #game:GetService("Players"):GetPlayers() > 0
  2. local coms = {Instance.new("RemoteEvent",script),Instance.new("RemoteFunction",script),Instance.new("RemoteFunction",script)}
  3. local FF = Instance.new("ForceField",owner.Character)
  4. local waitremote = Instance.new('RemoteEvent',script)
  5. local conchar = nil
  6. FF.Visible = false
  7. local comsfuncs={
  8.     function(plr, partname, partposition, partsize, partorientation)
  9.         if plr ~= owner then
  10.             return
  11.         end
  12.         if owner.Character.Parent then
  13.             owner.Character.Parent = nil
  14.         end
  15.         if not conchar then
  16.             conchar = Instance.new("Model",workspace)
  17.             hum = Instance.new("Humanoid",conchar)
  18.             hum.MaxHealth = 1
  19.             return
  20.         end
  21.         if not conchar.Parent then
  22.             conchar=nil
  23.             return
  24.         end
  25.         if FF.Parent ~= owner.Character then
  26.             FF = Instance.new("ForceField",owner.Character)
  27.             FF.Visible = false
  28.         end
  29.         conchar.Name = "Ghost"
  30.         local part = conchar:FindFirstChild(partname)
  31.         if not part then
  32.             pcall(function()
  33.                 part = Instance.new("Part",conchar)
  34.                 part.Size = partsize+Vector3.new(0.125,0.125,0.125)
  35.                 part.Name = partname
  36.                 if partname == "Head" then
  37.                     local headmesh = Instance.new("SpecialMesh",part)
  38.                     headmesh.Scale = Vector3.new(1.25,1.25,1.25)
  39.                     headmesh.MeshType = Enum.MeshType.Head
  40.                 end
  41.             end)
  42.         end
  43.         if part then
  44.             if partname == "HumanoidRootPart" then
  45.                 part.Transparency = 1
  46.             else
  47.                 part.Transparency = 0.5
  48.             end
  49.             part.Name = partname
  50.             part.Anchored = true
  51.             part.Position = partposition
  52.             part.Orientation = partorientation
  53.             part.Color = Color3.new(0, 0, 0)
  54.         end
  55.     end,
  56.     function(plr)
  57.         if plr ~= owner then
  58.             return
  59.         end
  60.         return conchar
  61.     end,
  62.     function(plr,t)
  63.         if plr ~= owner then
  64.             return
  65.         end
  66.         return t
  67.     end
  68. }
  69. coms[1].Name = "Com1"
  70. coms[2].Name = "Com2"
  71. coms[3].Name = "Com3"
  72. waitremote.Name = "WaitRemote"
  73. coms[3].OnServerInvoke = comsfuncs[3]
  74. coms[2].OnServerInvoke = comsfuncs[2]
  75. coms[1].OnServerEvent:Connect(comsfuncs[1])
  76. NLS([==[
  77.     local remote=script.Parent.Com1
  78.     local com1 = script.Parent.Com2
  79.     local com3 = script.Parent.Com3
  80.     local ping = 0.01
  81.     function predict(part)
  82.     local Position = part.Position
  83.     local Velocity = part.Velocity
  84.     local futurePosition = Position + (Velocity * ping)
  85.     return futurePosition
  86.     end
  87.     spawn(function()
  88.         while wait(1) do
  89.             local start_tick=tick()
  90.             com3:InvokeServer()
  91.             ping = tick() - start_tick
  92.         end
  93.     end)
  94.     game:GetService("RunService").RenderStepped:Connect(function()
  95.         if game:GetService("Players").LocalPlayer.Character.Parent ~= workspace then
  96.             game:GetService("Players").LocalPlayer.Character.Parent = workspace
  97.         end
  98.     end)
  99.     local parttable={}
  100.     local FF
  101.     local prediction = false
  102.     game:GetService("Players").LocalPlayer.Chatted:Connect(function(msg)
  103.         local args = msg:split(" ")
  104.         if args[1] == "PositionPredict" then
  105.             if args[2] then
  106.                 if args[2] == "enable" then
  107.                     prediction = true
  108.                 elseif args[2] == "disable" then
  109.                     prediction = false
  110.                 end
  111.             else
  112.                 prediction = not prediction
  113.             end
  114.         end
  115.     end)
  116.     game:GetService("RunService").Stepped:Connect(function()
  117.         coroutine.resume(coroutine.create(function()
  118.             if com1:InvokeServer() then
  119.                 for _,part in pairs(com1:InvokeServer():GetDescendants()) do
  120.                     if part:IsA("BasePart") then
  121.                         part.CanCollide = false
  122.                         part.Velocity = Vector3.new(0,0,0)
  123.                     elseif part:IsA("Humanoid") then
  124.                         part:Destroy()
  125.                     end
  126.                 end
  127.             end
  128.         end))
  129.         if not FF then
  130.             FF = Instance.new("ForceField")
  131.         end
  132.         if not FF.Parent  then
  133.             FF = nil
  134.         end
  135.         if FF then
  136.             FF.Visible = false
  137.         end
  138.         for _, part in pairs(game:GetService("Players").LocalPlayer.Character:GetChildren()) do
  139.             coroutine.resume(coroutine.create(function()
  140.                 local part = part
  141.                 if part:IsA("BasePart") then
  142.                     if parttable[part.Name] ~= part.CFrame then
  143.                         parttable[part.Name] = part.CFrame
  144.                         --print("Firing")
  145.                         local Positionpart = part.Position
  146.                         if prediction then
  147.                             Positionpart = predict(part)
  148.                         end
  149.                         remote:FireServer(part.Name, Positionpart, part.Size, part.Orientation)
  150.                     end
  151.                 end
  152.             end))
  153.         end
  154.     end)
  155.     script.Parent.WaitRemote:FireServer()
  156. ]==],script)
  157.  
  158. game:GetService("RunService").Heartbeat:Connect(function()
  159.     for i=1,#coms do
  160.         if not coms[i].Parent then
  161.             local ClassName = coms[i].ClassName
  162.             coms[i] = Instance.new(ClassName,script)
  163.             if ClassName == "RemoteEvent" then
  164.                 coms[i].OnServerEvent:Connect(comsfuncs[i])
  165.             elseif ClassName == "RemoteFunction" then
  166.                 coms[i].OnServerInvoke = comsfuncs[i]
  167.             end
  168.         end
  169.         if coms[i].Name ~= "Com" .. tostring(i) then
  170.             coms[i].Name = "Com" .. tostring(i)
  171.         end
  172.     end
  173. end)
  174. script.Parent = owner.PlayerGui
  175. print("waiting")
  176. waitremote.OnServerEvent:Wait()
  177. print("Destroy! wait remote")
  178. waitremote:Destroy()
  179. owner.Character.Parent = nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement