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

How to make character health equal maxHealth on death or join?

How do I make this work? It only gets set to 100 and not to full heatlh

player = game.Players.LocalPlayer

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		character.Humanoid.Health = character.Humanoid.MaxHealth
	end)
end)

2 comments

0

h=character.Humanoid.MaxHealth character.Humanoid.Health=h

0

Um...isn't this unnecessary? When a character is respawned, its health is automatically set to its MaxHealth.

1 answer

I don't know why you would ever want to do that, but...

I think you just got two scripts mixed up. It's supposed to look like this:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character.Humanoid.Health = character.Humanoid.MaxHealth
    end)
end)

And also, every humanoid has a died event. Might come in handy.

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