So the code is suppost to trigger whenever the player respawns the maxhealth goes up to 500, doesn't work on my part, This is made in a localscript.
here's the script:
game.Players.PlayerAdded:connect(function(Char) while wait(1) do Char.Humanoid.StatusAdded:connect(function() Char.Humanoid.MaxHealth = 1000 Char.Humanoid.Health = Char.Humanoid.MaxHealth end) end end)
There are a few issues here. Veer is correct: PlayerAdded doesn't work with LocalScripts, at least not in a way you would expect, so this has to be done through a normal Script.
PlayerAdded
when it fires returns the Player
, not their Character, and it only fires once for each Player - when they first join the game. You have to use the CharacterAdded
event to catch their respawns.
I'm not sure why you're using the StatusAdded
event of Humanoid: nothing internally will fire it, since that associated RBXLibrary was never completed.
This code should work for you: In a Script, preferably in ServerScriptService:
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Char) wait() --Allow the character to load fully Char.Humanoid.MaxHealth = 500 --You said you wanted it set to 500, not 1000 Char.Humanoid.Health = Char.Humanoid.MaxHealth end) end)