How can I make a revival script?

  1. What do you want to achieve? A script that makes a player come back to life after death. So basically is the character dies (health goes down to 0) and then they regenerate and come back.

  2. What is the issue? I don’t know where or how to start

  3. What solutions have you tried so far? I tried adding 100 health to the dead character once Humanoid.Died is fired

All help would be appreciated (just to clarify so I dont get attacked, I dont need the script I just want ideas on where to start)

Roblox already does that for you, automatically whenever the player dies, he will respawn.( as long ad you didnt disable it).

1 Like

I think the OP meant in the exact same place they died. Not at spawn.

1 Like

yeah as ValiantWind mentioned I want the character to be back where they died

(like when their health reaches 0 they like start regenerating and ‘come back to life’

You can simply store their last position/CFrame, and when his character loads again, move him to that pos/CFrame.

1 Like

Create a Server Script in ServerScriptService, paste in the following.

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
    Player.CharacterRemoving:Connect(function(Char)
        local lastPosition = Char.HumanoidRootPart.Position
        task.wait(Players.RespawnTime)
        Player.Character:MoveTo(lastPosition)
    end)
end)

Tell me if that resolved your problem.

Once the humanoid is in the dead state, it’s impossible for them to be revived. I suggest leaving them with 0.1 hp or something. Just make sure the hp is above 0 for it to not enter that state.
https://developer.roblox.com/en-us/api-reference/enum/HumanoidStateType

1 Like

I suggest you should use the Humanoid.Died function as it can be more accurate in certain circumstances of when the player dies.

Maybe this script will work?

local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
    Player.CharacterAdded:Connect(function(character)
        local Humanoid:  Humanoid = character:WaitForChild("Humanoid")
        character:WaitForChild("Humanoid").Died:Connect(function()
        Humanoid.Health = Humanoid.MaxHealth      
        character:MakeJoints()
        Humanoid:ChangeState(Enum.HumanoidStateType.Running)
        end)
    end)
end)
1 Like

apparently I have to keep them above 0 or there’s no going back, but thanks for the idea! (it kinda worked but the character was still like dead but at full health?)

1 Like