Codectionary / Developer documentation / Luau

Humanoid states

Observe movement states such as running, jumping, and falling.

Why use Humanoid?

Humanoid manages much of a character’s movement and health behavior. StateChanged helps react to a transition, such as showing an effect when a character lands.

Try it in Roblox Studio

Put this LocalScript in StarterCharacterScripts and start a client in Studio. Jump or fall to see state names in Output.

Syntax

humanoid.StateChanged:Connect(function(oldState, newState) ... end)

Examples

Humanoid states

Log state transitions for the local character.

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
assert(humanoid:IsA("Humanoid"))
humanoid.StateChanged:Connect(function(oldState, newState)
    print(oldState.Name, "->", newState.Name)
end)
  1. StarterCharacterScripts copies the LocalScript into each spawned character.
  2. WaitForChild handles the Humanoid appearing after the script starts.
  3. StateChanged passes both old and new Enum.HumanoidStateType values; the event reports transitions rather than continuously polling movement.

Best practices

  • Use the state signal for transitions rather than a per-frame polling loop.
  • Remember that server-authoritative gameplay should validate important movement effects.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading