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

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

Asked by 8 years ago

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

1player = game.Players.LocalPlayer
2 
3game.Players.PlayerAdded:connect(function(player)
4    player.CharacterAdded:connect(function(character)
5        character.Humanoid.Health = character.Humanoid.MaxHealth
6    end)
7end)
0
h=character.Humanoid.MaxHealth character.Humanoid.Health=h nohubris 0 — 8y
0
Um...isn't this unnecessary? When a character is respawned, its health is automatically set to its MaxHealth. jamesarsenault 192 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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:

1game.Players.PlayerAdded:connect(function(player)
2    player.CharacterAdded:connect(function(character)
3        character.Humanoid.Health = character.Humanoid.MaxHealth
4    end)
5end)

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

Ad

Answer this question