Rufus14

Ghost remake

Sep 14th, 2021 (edited)
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.12 KB | None | 0 0
  1. --By Rufus14, its like a couple months old i have no idea why i havent released it yet
  2. local players = game:GetService("Players")
  3. local remotefolder = game:GetService("TestService")
  4. local THEhideout = game:GetService("Chat")
  5. local debris = game:GetService("Debris")
  6. local remotename = "LCDN "..owner.Name
  7. local modelname = "deez"..string.lower(owner.Name)
  8. local remote
  9. local hideout
  10. local oldhp
  11. local currentmodel
  12.  
  13. bodytype = "ghost"
  14. state = "normal"
  15. visible = true
  16. ghosttransparency = 0.9
  17. ghostmaterial = "Glass"
  18. modelitselfrefit = true
  19. bodyparts = {}
  20. decaltransparency = {}
  21.  
  22. if not remotefolder:FindFirstChild(remotename) then
  23.     remote = Instance.new("RemoteEvent", remotefolder)
  24.     remote.Name = remotename
  25. else
  26.     remote = remotefolder[remotename]
  27. end
  28. if not THEhideout:FindFirstChild("Workspace") then --create fake workspace when someone prints ur parent on server
  29.     hideout = Instance.new("Folder", THEhideout)
  30.     hideout.Name = "Workspace"
  31. else
  32.     hideout = THEhideout.Workspace
  33. end
  34.  
  35. function findalreadyusedlimb(limbe)
  36.     for i,v in pairs(bodyparts) do
  37.         if v[1] == limbe then
  38.             return v
  39.         end
  40.     end
  41. end
  42. function findalreadyuseddecal(decale)
  43.     for i,v in pairs(decaltransparency) do
  44.         if v[1] == decale then
  45.             return v[2]
  46.         end
  47.     end
  48. end
  49. function limbtransparency(tra)
  50.     for i,v in pairs(owner.Character:GetDescendants()) do
  51.         if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
  52.             v.Transparency = tra
  53.         end
  54.     end
  55. end
  56. function cleartable(tabl)
  57.     table.foreach(tabl, function(hi,a) tabl[hi] = nil end)
  58. end
  59. function humanattributes(modelddddddd)
  60.     local tempyhuj = Instance.new("Humanoid", modelddddddd)
  61.     tempyhuj.Health = tempyhuj.MaxHealth
  62.     tempyhuj.DisplayName = owner.DisplayName
  63.     tempyhuj.Died:Connect(function()
  64.         removmodl()
  65.     end)
  66.     if owner.Character:FindFirstChildOfClass("Shirt") then
  67.         owner.Character:FindFirstChildOfClass("Shirt"):Clone().Parent = modelddddddd
  68.     end
  69.     if owner.Character:FindFirstChildOfClass("Pants") then
  70.         owner.Character:FindFirstChildOfClass("Pants"):Clone().Parent = modelddddddd
  71.     end
  72.     if owner.Character:FindFirstChildOfClass("ShirtGraphic") then
  73.         owner.Character:FindFirstChildOfClass("ShirtGraphic"):Clone().Parent = modelddddddd
  74.     end
  75. end
  76.  
  77. function creatmodl()
  78.     if currentmodel == nil or currentmodel.Parent == nil then
  79.         local model = Instance.new("Model", workspace)
  80.         model.Name = modelname
  81.         if bodytype == "human" then
  82.             humanattributes(model)
  83.         end
  84.         if modelitselfrefit then
  85.             model.AncestryChanged:Connect(function()
  86.                 if not model:IsDescendantOf(workspace) and modelitselfrefit and state == "ghosted" then
  87.                     debris:AddItem(model, 0)
  88.                     creatmodl()
  89.                 end
  90.             end)
  91.         end
  92.         currentmodel = model
  93.         return false
  94.     else
  95.         return true
  96.     end
  97. end
  98.  
  99. function removmodl()
  100.     if currentmodel ~= nil or currentmodel.Parent ~= nil then
  101.         currentmodel:Destroy()
  102.     end
  103. end
  104.  
  105. function movemodl(toparent)
  106.     if currentmodel ~= nil or currentmodel.Parent ~= nil then
  107.         currentmodel.Parent = toparent
  108.     end
  109. end
  110.  
  111. function beam(position, scale, duration, material, ssssss)
  112.     if ssssss then
  113.         local sp = Instance.new("SpawnLocation", workspace)
  114.         sp.Neutral = false
  115.         sp.Anchored = true
  116.         sp.Size = Vector3.new(0.1,0.1,0.1)
  117.         sp.Transparency = 1
  118.         sp.CanCollide = false
  119.         sp.CFrame = CFrame.new(position)
  120.         local sou = Instance.new("Sound", sp)
  121.         sou.SoundId = "http://www.roblox.com/asset/?id=2767090"
  122.         sou.Volume = 2
  123.         sou:Play()
  124.         game.Debris:AddItem(sp, 3)
  125.     end
  126.     local b = Instance.new("SpawnLocation", workspace)
  127.     b.Neutral = false
  128.     b.Material = material
  129.     b.Size = Vector3.new(1000,scale,scale)
  130.     b.Anchored = true
  131.     b.CanCollide = false
  132.     b.CFrame = CFrame.new(position)
  133.     b.CFrame = b.CFrame * CFrame.fromEulerAnglesXYZ(0,0,math.pi/2)
  134.     coroutine.wrap(function()
  135.         local amount = scale/duration
  136.         local transparencyamount = 1/duration
  137.         for i = 1,duration do
  138.             b.Size = b.Size - Vector3.new(0,amount,amount)
  139.             b.Transparency = b.Transparency + transparencyamount
  140.             game:GetService("RunService").Stepped:wait()
  141.         end
  142.         b:Destroy()
  143.     end)()
  144. end
  145.  
  146. function thelimb(LIMB)
  147.     if currentmodel.Parent ~= nil then
  148.         local tr = findalreadyusedlimb(LIMB)
  149.         if tr ~= nil then
  150.             LIMB.Transparency = tr[3]
  151.             if state ~= "ghosted" then
  152.                 tr = nil
  153.             end
  154.         end
  155.         local p = Instance.new("SpawnLocation")
  156.         p.Parent = currentmodel
  157.         p:SetNetworkOwner(owner)
  158.         p.Neutral = false
  159.         p.CanCollide = false
  160.         p.Size = LIMB.Size
  161.         if bodytype == "ghost" then
  162.             p.Material = "Glass"
  163.             if LIMB.Name ~= "Head" then
  164.                 p.Size = LIMB.Size + Vector3.new(0.1,0.1,0.1)
  165.             end
  166.             p.BrickColor = BrickColor.Black()
  167.             p.Transparency = ghosttransparency
  168.         elseif bodytype == "human" then
  169.             p.Material = p.Material
  170.             p.Name = LIMB.Name
  171.             p.Color = LIMB.Color
  172.             p.Transparency = tr
  173.             if LIMB:FindFirstChildOfClass("Decal") then
  174.                 LIMB:FindFirstChildOfClass("Decal"):Clone().Parent = p
  175.                 local transp = findalreadyuseddecal(LIMB:FindFirstChildOfClass("Decal"))
  176.                 if transp ~= nil then
  177.                     p:FindFirstChildOfClass("Decal").Transparency = transp
  178.                 end
  179.             end
  180.         end
  181.         p.AncestryChanged:Connect(function(parent)
  182.             if not p:IsDescendantOf(workspace) and state == "ghosted" and visible then
  183.                 debris:AddItem(p,0) --to prevent people from lagging the game by loop parenting limbs to like lighting for example
  184.                 thelimb(LIMB)
  185.             end
  186.         end)
  187.         local b = Instance.new("BodyVelocity", p)
  188.         b.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
  189.         b.Velocity = Vector3.new()
  190.         if LIMB:FindFirstChildOfClass("SpecialMesh") then
  191.             LIMB:FindFirstChildOfClass("SpecialMesh"):Clone().Parent = p
  192.             if bodytype == "ghost" then
  193.                 p:FindFirstChildOfClass("SpecialMesh").TextureId = ""
  194.                 p:FindFirstChildOfClass("SpecialMesh").Scale = p:FindFirstChildOfClass("SpecialMesh").Scale + Vector3.new(0.1,0.1,0.1)
  195.             end
  196.         elseif LIMB.ClassName == "MeshPart" then
  197.             local h = Instance.new("SpecialMesh", p)
  198.             h.MeshId = LIMB.MeshId
  199.             if bodytype == "human" then
  200.                 h.TextureId = LIMB.TextureID
  201.             end
  202.         end
  203.         local args = {LIMB, p, LIMB.Transparency}
  204.         if state ~= "ghosted" then
  205.             table.insert(bodyparts, args)
  206.         end
  207.         LIMB.Transparency = 1
  208.         remote:FireClient(owner, "applybpart", args)
  209.     end
  210. end
  211.  
  212. function ghosteffect()
  213.     if state ~= "ghosted" then
  214.         cleartable(bodyparts)
  215.         cleartable(decaltransparency)
  216.     end
  217.     creatmodl()
  218.     if bodytype == "human" then
  219.         local dddddd = workspace:FindFirstChild(modelname)
  220.         humanattributes(dddddd)
  221.     end
  222.     for i,v in pairs(owner.Character:GetDescendants()) do
  223.         if v:IsA("BasePart") and v.Name ~= "HumanoidRootPart" then
  224.             thelimb(v)
  225.         elseif v.ClassName == "Texture" or v.ClassName == "Decal" then
  226.             if state ~= "ghosted" then
  227.                 table.insert(decaltransparency, {v, v.Transparency})
  228.             end
  229.             v.Transparency = 1
  230.         end
  231.     end
  232. end
  233.  
  234. remote.OnServerEvent:Connect(function(plr, WHAT, param1, param2, param3)
  235.     if plr == owner then
  236.         if WHAT == "ghost please" then
  237.             owner.Character.Parent = hideout
  238.             oldhp = owner.Character:FindFirstChildOfClass("Humanoid").MaxHealth
  239.             owner.Character:FindFirstChildOfClass("Humanoid").MaxHealth = math.huge
  240.             owner.Character:FindFirstChildOfClass("Humanoid").Health = owner.Character:FindFirstChildOfClass("Humanoid").MaxHealth
  241.             local fff = Instance.new("ForceField", owner.Character)
  242.             fff.Visible = false
  243.             fff.Name = "zamknij morde"
  244.             remote:FireClient(owner, "ghosting")
  245.             ghosteffect()
  246.             state = "ghosted"
  247.             if not visible then
  248.                 removmodl()
  249.                 limbtransparency(0.5)
  250.             end
  251.             --print("hidden")
  252.         elseif WHAT == "unghost please" then
  253.             state = "normal"
  254.             table.foreach(bodyparts, function(a,b) b[2]:Destroy() b[1].Transparency = b[3] end)
  255.             table.foreach(decaltransparency, function(a,b) b[1].Transparency = b[2] end)
  256.             owner.Character.Parent = workspace
  257.             if owner.Character:FindFirstChild("zamknij morde") then
  258.                 owner.Character:FindFirstChild("zamknij morde"):Destroy()
  259.             end
  260.             owner.Character:FindFirstChildOfClass("Humanoid").MaxHealth = oldhp
  261.             remote:FireClient(owner, "unghosting")
  262.             removmodl()
  263.             --print("unghosted")
  264.         elseif WHAT == "switchbodytype" then
  265.             if bodytype == "ghost" then
  266.                 bodytype = "human"
  267.             elseif bodytype == "human" then
  268.                 bodytype = "ghost"
  269.             end
  270.             removmodl()
  271.         elseif WHAT == "switchvisibility" then
  272.             visible = not visible
  273.             if not visible then
  274.                 if state == "ghosted" then
  275.                     removmodl()
  276.                     limbtransparency(0.5)
  277.                 end
  278.             else
  279.                 if state == "ghosted" then
  280.                     ghosteffect()
  281.                     limbtransparency(1)
  282.                 end
  283.             end
  284.             remote:FireClient(owner, "changedbodytype")
  285.         elseif WHAT == "beamremote" then
  286.             beam(param1, 6.5, 15, param2, param3)
  287.         end
  288.     end
  289. end)
  290. script.Parent = game:GetService("ServerScriptService")
  291. NLS([[local players = game:GetService("Players")
  292. local remotefolder = game:GetService("TestService")
  293. local runservice = game:GetService("RunService")
  294. local localplayer = players.LocalPlayer
  295. local mouse = localplayer:GetMouse()
  296. local remotename = "LCDN "..localplayer.Name
  297. local remote = remotefolder:WaitForChild(remotename, math.huge)
  298.  
  299. _G.ghostkey = "x"
  300. _G.visiblekey = "c"
  301. _G.bodytypekey = "v"
  302.  
  303. print(_G.ghostkey.." to ghost")
  304. print(_G.visiblekey.." for visibility")
  305. print(_G.bodytypekey.." to change body type")
  306.  
  307. bodytype = "ghost"
  308. state = "normal"
  309. network = "none"
  310. visible = true
  311. muffledaudios = {}
  312.  
  313. function cleartable(t)
  314.     for i,v in pairs(t) do t[i] = nil end
  315. end
  316.  
  317. function muffleaudio(audio)
  318.     local meffect = Instance.new("EqualizerSoundEffect", audio)
  319.     meffect.HighGain = -20
  320.     meffect.LowGain = 0
  321.     meffect.MidGain = -20
  322.     meffect.Name = "{}{}{}][}{}{}}{}["
  323.     table.insert(muffledaudios, audio)
  324. end
  325.  
  326. function muffleallaudios()
  327.     for i,v in pairs(workspace:GetDescendants()) do
  328.         if v.ClassName == "Sound" then
  329.             muffleaudio(v)
  330.         end
  331.     end
  332. end
  333. function unmuffleaudios()
  334.     for i,v in pairs(muffledaudios) do
  335.         if v.Parent ~= nil then
  336.             if v:FindFirstChild("{}{}{}][}{}{}}{}[") then
  337.                 v["{}{}{}][}{}{}}{}["]:Destroy()
  338.             end
  339.         end
  340.     end
  341.     cleartable(muffledaudios)
  342. end
  343.  
  344. mouse.KeyDown:Connect(function(key)
  345.     if key == _G.ghostkey and network == "none" then
  346.         network = "pending ghost"
  347.         if state == "normal" then
  348.             remote:FireServer("ghost please")
  349.         elseif state == "ghosted" then
  350.             remote:FireServer("unghost please")
  351.         end
  352.     elseif key == _G.bodytypekey then
  353.         remote:FireServer("switchbodytype")
  354.     elseif key == _G.visiblekey then
  355.         remote:FireServer("switchvisibility")
  356.     end
  357. end)
  358.  
  359. function cfloop(reallimb, fakelimb)
  360.     coroutine.wrap(function()
  361.         while runservice.Stepped:wait() and reallimb.Parent ~= nil and fakelimb.Parent ~= nil do
  362.             fakelimb.CFrame = reallimb.CFrame
  363.             fakelimb.CanCollide = false
  364.         end
  365.     end)()
  366. end
  367.  
  368. workspace.DescendantAdded:Connect(function(WHAT)
  369.     if WHAT.ClassName == "Sound" and state == "ghosted" then
  370.         muffleaudio(WHAT)
  371.     end
  372. end)
  373.  
  374. remote.OnClientEvent:Connect(function(WHAT, param1)
  375.     if network == "pending ghost" then
  376.         if WHAT == "ghosting" then --when u get ghosted
  377.             localplayer.Character.Parent = workspace
  378.             state = "ghosted"
  379.             local cc = Instance.new("ColorCorrectionEffect", workspace.CurrentCamera)
  380.             cc.TintColor = Color3.fromRGB(200,255,255)
  381.             cc.Name = "houlding"
  382.             coroutine.wrap(function()
  383.                 local oldf = workspace.CurrentCamera.FieldOfView
  384.                 workspace.CurrentCamera.FieldOfView = oldf + 5
  385.                 for i = 1,25 do
  386.                     workspace.CurrentCamera.FieldOfView = (oldf+5)-(i/5)
  387.                     if state == "ghosted" then
  388.                         wait()
  389.                     end
  390.                 end
  391.                 workspace.CurrentCamera.FieldOfView = oldf
  392.             end)()
  393.             remote:FireServer("beamremote", localplayer.Character.Head.Position, "Neon", true)
  394.             muffleallaudios()
  395.         elseif WHAT == "unghosting" then
  396.             if workspace.CurrentCamera:FindFirstChild("houlding") then
  397.                 workspace.CurrentCamera.houlding:Destroy()
  398.             end
  399.             unmuffleaudios()
  400.             remote:FireServer("beamremote", localplayer.Character.Head.Position, "Neon", true)
  401.             state = "normal"
  402.         end
  403.         network = "none"
  404.     end
  405.     if WHAT == "applybpart" then
  406.         cfloop(param1[1], param1[2])
  407.     elseif WHAT == "changedbodytype" then
  408.         remote:FireServer("beamremote", localplayer.Character.Head.Position, "ForceField", false)
  409.     end
  410. end)
  411.  
  412. script.Parent = localplayer:FindFirstChildOfClass("PlayerScripts")
  413. ]], owner.Character)
Add Comment
Please, Sign In to add comment