Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to run this code every respawn?

Asked by 9 years ago
script.Parent.Parent.Character.Humanoid.Health = script.Parent.Parent.Character.Humanoid.MaxHealth

so everytime the character respawns his health is at max thanks :)

1 answer

Log in to vote
1
Answered by 9 years ago

You could just use a server script for this. Every time a player is added and their character is added or respawned, you can set their Humanoid's health to their MaxHealth.

game.Players.PlayerAdded:connect(function(plr) --When a player is added.
    plr.CharacterAdded:connect(function(char) --When that player's character is added/respawned.
        local hum = char:WaitForChild("Humanoid") --Waits for the Humanoid to become available.
        hum.Health = hum.MaxHealth --Sets the Humanoid's health to max health.
    end)
end)

However, I don't see why you are doing this because a player spawns in with maximum health already, unless you're using another script to change their max health as they spawn.

I hope I answered your question. If I did, be sure to accept my answer.

0
yes i did answer my question thanks ;) , and the script is for my RPG, in which their health gradually increases every level etc. thanks again! Bubbles5610 217 — 9y
0
No problem. Spongocardo 1991 — 9y
Ad

Answer this question