So with this code in a normal script in StarterCharacterScripts inside StarterPlayer it only changes 1 Players maxhealth. I cant find the reason for that.
1 | game.Players.PlayerAdded:Connect( function (plr) |
2 | plr.CharacterAdded:connect( function (Char) --fires when the character is added, this includes when the player dies aswell |
3 | if Char:FindFirstChild( "Humanoid" ) then |
4 | Char.Humanoid.MaxHealth = 200 --Change max health first |
5 | Char.Humanoid.Health = 200 -- then change the health itself |
6 | print ( "Health changed for" ..plr.Name) |
7 | end |
8 | end ) |
9 | end ) |
EDIT: Its random if a player gets the new maxhealth or not. So sometimes 0 players and sometimes 1 or more
I can see one major problem at first glance, that being PlayerAdded is a server event, and using it on the client shouldn't work. Therefore, this should be in a script located preferably in ServerScriptService.
Add a wait(1) in between line 2 and 3