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

Changing the MAX Health of all Players not working?

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.

game.Players.PlayerAdded:Connect(function(plr)
	    plr.CharacterAdded:connect(function(Char) --fires when the character is added, this includes when the player dies aswell
	        if Char:FindFirstChild("Humanoid") then
	            Char.Humanoid.MaxHealth = 200 --Change max health first
	            Char.Humanoid.Health = 200 -- then change the health itself
		print("Health changed for"..plr.Name)
	        end
	    end)
	end)

EDIT: Its random if a player gets the new maxhealth or not. So sometimes 0 players and sometimes 1 or more

2 answers

✓ Accepted answer

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.

1 comment

0

thats true, Thanks!

Add a wait(1) in between line 2 and 3

2 comments

0

Nope. Didnt fix it. Still players who only got 100 max hp

0

Adding wait() like a mad-man won't fix anything

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