Health is not a valid member of player

whenever some person joins it has a chance for this to happen and break the game, it’s unacceptable that it breaks the whole system when it triggers an error so i cant really do much about it
the error

it will be a big help if you can help me get this fixed thanks.

Use :WaitForChild() to prevent erroring if something doesn’t exist yet.

I assume when this happens you’re trying to reference health by Player.Health, when the player instance doesn’t have an attribute for health. This means that you’ll have to go to the players humanoid, where the health is located, and fetch it there. For example, it’d look something like such:

local player = -- However you get the player
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:FindFirstChild("Humanoid")
print(hum.Health) 
1 Like

so i already tried that before and it crashes the whole script

At the line 1, i often use this:

wait(0.5)
repeat wait() until game.Players.LocalPlayer.Character.Humanoid —if it is a server script, you can replace LocalPlayer by Player, plr or whatever it is named

so, what you can do is smth like this:

game.Players.PlayerAdded:connect(function(plr)
      plr.CharacterAdded:connect(function(chr) -- meants they have a character now
            local hum = chr:WaitForChild'Humanoid'
            print(hum.Health, hum.MaxHealth, "got Humanoid")
      end)
end)

OR

local chr = Player.Character or Player.CharacterAdded:Wait()
local hum = chr:WaitForChild'Humanoid'
print('got humanoid', hum.Health, hum.MaxHealth)