PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

StateEnabledChanged

The StateEnableChanged event fires when Humanoid/SetStateEnabled is called on the Humanoid.

Parameters include the Enum/HumanoidStateType in question along with a bool indicating if this state is now enabled.

See also

  • To find if a state is currently enabled, use Humanoid/GetStateEnabled
  • To listen to Humanoid state changes use Humanoid/StateChanged

Parameters

Name Type Default Description

The Enum/HumanoidStateType for which the enabled state has been changed

True if the state is now enabled


Code Samples


Humanoid State Change Detector

When a humanoid state changes for the Players/LocalPlayer, the code below prints whether the state has been enabled or disabled.

This code should work as expected when placed in a LocalScript.

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:wait()
local humanoid = character.Humanoid

humanoid.StateEnabledChanged:Connect(function(state, enabled)
	if enabled then
		print(state.Name.." has been enabled")
	else
		print(state.Name.." has been disabled")
	end
end)