Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to run this code every respawn?

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

✓ Accepted answer

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.

2 comments

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!

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.