The body your player controls — when it spawns, how to grab it safely, and the Humanoid that keeps it alive.
The Player is the account. Now meet the body they control: the character — and the Humanoid inside it that keeps it standing, walking, and alive.
The character doesn't exist when a player joins. It appears a moment later — which is exactly what CharacterAdded is for:
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
print(player.Name .. " spawned a new body")
end)
end)
Every respawn is a new character and a fresh CharacterAdded. If you grab player.Character at join time, it's nil — the body isn't there yet. Listen for the event; grab the character in its callback.
Why wait for CharacterAdded instead of reading player.Character directly?
The character's parts load over a few frames. Asking for a child that isn't loaded yet errors:
local humanoid = character:WaitForChild("Humanoid")
WaitForChild("Humanoid") waits patiently until the child exists, then returns it. Use it whenever you grab children that might not exist yet. The "Wait" in the name is the whole point.
It's tempting to write character.Humanoid directly — and it works most of the time. WaitForChild removes the "most of the time" and makes the load order a non-issue.
The method that waits until a child exists, then returns it, is
Inside every character is a Humanoid: the object that handles health, speed, walking, and death.
local humanoid = character:WaitForChild("Humanoid")
print("Health: " .. humanoid.Health .. " / " .. humanoid.MaxHealth)
humanoid.Health = humanoid.MaxHealth -- heal
humanoid.Health = humanoid.Health - 10 -- damage
humanoid.WalkSpeed = 40 -- speed boost
Health runs 0 to MaxHealth. At 0, the character dies and respawns. WalkSpeed is how fast they move — same Humanoid, different property.
Health is replicated game data. Change it on the server, or the server will disagree and correct you. Damage to real players always happens server-side.
A character just spawned. Write the line that heals it to full by setting Health to its MaxHealth.
local humanoid = character:WaitForChild("Humanoid")
-- heal the character
player.Character.Humanoid at join time = nil error. Wait for the event, or WaitForChild.Next: building the world itself from scripts — instances.