Player.Added event not changing player's hp

So I want to make it where the player’s hp is already changed as soon as they join the game, however its not working.

game.Players.PlayerAdded:Connect(function(player)
       player.Character.Humanoid.MaxHealth = 1
	   player.Character.Humanoid.Health = 1
end

Is this a server script or local script?

Also you should probably access the Character through the CharacterAdded :slightly_smiling_face:

You can’t assume that once a player has joined the game their character has instantly loaded.

Include a CharacterAdded event or similar.

(Sorry @Angiris_treecreeper wasn’t trying to copy your answer)

No problem :slightly_smiling_face:, Only here to help. All information is welcome

This is the current script rn, however it only changes the health only when the player has died once

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		player.Character.Humanoid.MaxHealth = 1
		player.Character.Humanoid.Health = 1
	end)
end)

So if this is in a local script its probably this issue again:

Basically the Local Player is already loaded so the PlayerAdded event won’t be fired on the initial join.

This is in a server script… so

Ah okay. I just tested it out and it seems to work fine for me. Try printing the value and see what it says.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		
		player.Character.Humanoid.MaxHealth = 1
		player.Character.Humanoid.Health = 1
		
		print(player.Character.Humanoid.MaxHealth)
	end)
end)