Hello! I’m trying to make a system to revive a player when he dies but I couldn’t make it because I have many issues, I think revival system that I want it’s quite difficult, I tried to search everywhere like DevForum, YouTube, Discord but nothing that solves my problem.
In conclusion I want to make that when a player dies he has the option to wait for a paramedic team or to restart immediately, but when he restarts with the Roblox default button the player can respawn normally like in all games.
So store a clone of the players character and then change player.character to the clone and move over the camera and set position to where the body is and delete the body.
Instead of using the Roblox health system, create your own and use that to your advantage. Make sure to do team checks and other checks to make sure other players can’t revive non-teammates and stuff like that. Animations should be easy enough to load in and play.
Thanks! I have it almost ready, but I have two problems:
When I set that only team can revive, the proximity prompt stopped displaying and I don’t know how to fix it. (Line 22)
Revive Script
(Server Script)
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")
Players.PlayerAdded:Connect(function(Player)
local DeathCFrame = Instance.new("CFrameValue")
DeathCFrame.Value = CFrame.new()
DeathCFrame.Name = "DeathCFrame"
DeathCFrame.Parent = Player
Player.CharacterAdded:Connect(function(Character)
if Player.DeathCFrame.Value ~= CFrame.new() then
repeat task.wait() until Character:WaitForChild("HumanoidRootPart")
Character.HumanoidRootPart.CFrame = Player.DeathCFrame.Value
Player.DeathCFrame.Value = CFrame.new()
end
local Humanoid = Character.Humanoid
Humanoid.HealthChanged:Connect(function(Health)
Player.DeathCFrame.Value = Character.HumanoidRootPart.CFrame
for _, v in pairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
if Player.Team == Teams.Paramedic then
local ProximityPrompt = Instance.new("ProximityPrompt")
ProximityPrompt.Parent = Character.HumanoidRootPart
ProximityPrompt.ObjectText = Player.Name
ProximityPrompt.ActionText = "Revive"
ProximityPrompt.HoldDuration = 5
ProximityPrompt.RequiresLineOfSight = false
ProximityPrompt.Enabled = false
task.wait(.25)
ProximityPrompt.Enabled = true
ReplicatedStorage.Handler:FireClient(Player, "HidePrompt", ProximityPrompt)
ProximityPrompt.Triggered:Connect(function(TriggPlayer)
if TriggPlayer.Character.Humanoid.Health >= 1 then
Player:LoadCharacter()
ProximityPrompt:Destroy()
end
end)
end
end
end
end)
end)
Player:LoadCharacter()
end)
When I respawn with the default button of Roblox I added a BillboardGui in the player’s head, but for some reason only the local player can see the timer and the others can’t, but it’s not a very important problem.
Script 1
(Local Script)
repeat wait() until game and game.Workspace and game.ReplicatedStorage.ResetEvent
local bind = game.ReplicatedStorage.ResetEvent
game:GetService("StarterGui"):SetCore("ResetButtonCallback", bind)
bind.Event:connect(function()
game.ReplicatedStorage.RemoteResetEvent:FireServer(10)
end)
Script 2
(Server Script)
repeat wait() until game.ReplicatedStorage.ResetEvent
local bind = game.ReplicatedStorage.ResetEvent
game.ReplicatedStorage.RemoteResetEvent.OnServerEvent:connect(function(plr,count)
if plr and plr.Character then
local gui = game.ServerStorage.BillboardGui:Clone()
gui.Timer.Value = count
gui.Parent = plr.Character.Head
end
end)
Script 3
(Local Script)
local plr = game.Players.LocalPlayer
repeat wait() until plr and plr.Character and script.Parent.Timer
plr.Character["HumanoidRootPart"].Anchored = true
for i = 1, script.Parent.Timer.Value do
script.Parent.Frame.NumberLabel.Text = script.Parent.Timer.Value-i
wait(1)
end
local Player = game:GetService("Players").LocalPlayer
game.ReplicatedStorage.RemoteEvent:FireServer(Player)
I found a possible solution. This makes that all players can see the proximity prompt to revive but they will not be able to revive the player if they are not in the paramedic team, I changed line 22 to line 35 and that works.
It wasn’t the solution I wanted but at least everyone who isn’t a paramedic won’t be able to revive the player. Although if anyone knows how to make it so that only paramedics can see the proximity prompt that would help me a lot if you tell me how.
You are creating a new ProximtyPromt every time the user’s health is changed, which is terrible. I’d create one and use the enable and disable function and that may be why it keeps disappearing for you.
You are updating the time on the client, not the server as you can see in your 3’rd script. You MUST update the text on the server so it updates for everyone, not just one person.
Thank for that! I made some changes to the script, now the proximity prompt is created only when player joins to game, but now all teams can revive players from paramedic team so now the downed player must be a paramedic to be revived, how I do to fix that? I want paramedics to have the ability to revive players from all teams in the game, and the other teams cannot revive no one.
Here is the script I changed:
Summary
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teams = game:GetService("Teams")
Players.PlayerAdded:Connect(function(Player)
local DeathCFrame = Instance.new("CFrameValue")
DeathCFrame.Value = CFrame.new()
DeathCFrame.Name = "DeathCFrame"
DeathCFrame.Parent = Player
local ProximityPrompt = Instance.new("ProximityPrompt")
ProximityPrompt.ObjectText = Player.Name
ProximityPrompt.ActionText = "Revive"
ProximityPrompt.HoldDuration = 5
ProximityPrompt.RequiresLineOfSight = false
ProximityPrompt.Enabled = false
Player.CharacterAdded:Connect(function(Character)
if not Character.HumanoidRootPart:FindFirstChild("ProximityPrompt") then
ProximityPrompt.Parent = Player.Character.HumanoidRootPart
else
if Player.DeathCFrame.Value ~= CFrame.new() then
repeat task.wait() until Character:WaitForChild("HumanoidRootPart")
Character.HumanoidRootPart.CFrame = Player.DeathCFrame.Value
Player.DeathCFrame.Value = CFrame.new()
end
end
if Player.Team == Teams.Paramedic then
local Humanoid = Character.Humanoid
Humanoid.HealthChanged:Connect(function(Health)
Player.DeathCFrame.Value = Character.HumanoidRootPart.CFrame
for _, v in pairs(Character:GetDescendants()) do
if v:IsA("Motor6D") then
task.wait(.25)
ProximityPrompt.Enabled = true
ReplicatedStorage.Handler:FireClient(Player, "HidePrompt", ProximityPrompt)
ProximityPrompt.Triggered:Connect(function(TriggPlayer)
if TriggPlayer.Character.Humanoid.Health >= 1 then
Player:LoadCharacter()
ProximityPrompt.Enabled = false
end
end)
end
end
end)
end
end)
Player:LoadCharacter()
end)