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 7 years ago

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)
0
h=character.Humanoid.MaxHealth character.Humanoid.Health=h nohubris 0 — 7y
0
Um...isn't this unnecessary? When a character is respawned, its health is automatically set to its MaxHealth. jamesarsenault 192 — 7y

1 answer

Log in to vote
0
Answered by 7 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:

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.

Ad

Answer this question