elvinfcb9
(ElvinYaeger)
#1
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 
xZylter
(xZylter)
#3
You can’t assume that once a player has joined the game their character has instantly loaded.
Include a CharacterAdded event or similar.
No problem
, Only here to help. All information is welcome
elvinfcb9
(ElvinYaeger)
#5
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.
elvinfcb9
(ElvinYaeger)
#7
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)