Advertisement
luchitasin9

Server Script

Aug 21st, 2022
1,188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | Source Code | 0 0
  1. local Players = game:GetService("Players")
  2. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  3.  
  4. Players.PlayerAdded:Connect(function(Player)
  5.     local DeathCFrame = Instance.new("CFrameValue")
  6.     DeathCFrame.Value = CFrame.new()
  7.     DeathCFrame.Name = "DeathCFrame"
  8.     DeathCFrame.Parent = Player
  9.    
  10.     Player.CharacterAdded:Connect(function(Character)
  11.         if Player.DeathCFrame.Value ~= CFrame.new() then
  12.             repeat task.wait() until Character:WaitForChild("HumanoidRootPart")
  13.             Character.HumanoidRootPart.CFrame = Player.DeathCFrame.Value
  14.             Player.DeathCFrame.Value = CFrame.new()
  15.         end
  16.        
  17.         local Humanoid = Character.Humanoid
  18.         Humanoid.BreakJointsOnDeath = false
  19.         Humanoid.Died:Connect(function()
  20.             Player.DeathCFrame.Value = Character.HumanoidRootPart.CFrame
  21.             for _, v in pairs(Character:GetDescendants()) do
  22.                 if v:IsA("Motor6D") then
  23.                     local Attachment0, Attachment1 = Instance.new("Attachment"), Instance.new("Attachment")
  24.                     Attachment0.CFrame = v.C0
  25.                     Attachment1.CFrame = v.C1
  26.                     Attachment0.Parent = v.Part0
  27.                     Attachment1.Parent = v.Part1
  28.                    
  29.                     local BSC = Instance.new("BallSocketConstraint")
  30.                     BSC.Attachment0 = Attachment0
  31.                     BSC.Attachment1 = Attachment1
  32.                     BSC.Parent = v.Parent
  33.                    
  34.                     v:Destroy()
  35.                 end
  36.             end
  37.            
  38.             local PP = Instance.new("ProximityPrompt")
  39.             PP.Parent = Character.HumanoidRootPart
  40.             PP.ObjectText = Player.Name
  41.             PP.ActionText = "Revive"
  42.             PP.HoldDuration = 5
  43.             PP.RequiresLineOfSight = false
  44.             PP.Enabled = false
  45.             task.wait(.25)
  46.             PP.Enabled = true
  47.             ReplicatedStorage.Handler:FireClient(Player, "HidePrompt", PP)
  48.            
  49.             PP.Triggered:Connect(function(TriggPlayer)
  50.                 if TriggPlayer.Character.Humanoid.Health >= 1 then
  51.                     Player:LoadCharacter()
  52.                     PP:Destroy()
  53.                 end
  54.             end)
  55.         end)
  56.     end)
  57.     Player:LoadCharacter()
  58. end)
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement