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

AutoRotate

Humanoid

bool

The AutoRotate property is a boolean that describes whether or not the Humanoid will automatically rotate to face in the direction they are moving. When set to true, the character model will gradually turn to face their movement direction as the Humanoid walks around. When set to false, the character model will remain fixated in its current rotation, unless a rotating force is applied to the HumanoidRootPart.

If the character model happens to be the character of a player, then the behavior of the Humanoid’s rotation is influenced by the UserGameSetting’s RotateType property.

When the AutoRotate property is set to true, the RotateType property has the following effects on the Humanoid’s rotation:

RotationType Behavior Context
CameraRelative Character will rotate to face in the direction of the camera. Player has their camera zoomed into first-person, or they are in shift-lock mode.
CameraRelative Character will rotate to face in the direction of the camera. Player has their camera zoomed into first-person, or they are in shift-lock mode.

Code Samples


AutoRotate Button

This script adds the functionality of a button to a part, which switches the AutoRotate property of whoever touches it.

local button = script.Parent
local enabled = true

local ON_COLOR = BrickColor.Green()
local OFF_COLOR = BrickColor.Red()

local function touchButton(humanoid)
	if enabled then
		enabled = false
		button.BrickColor = OFF_COLOR
		
		if humanoid.AutoRotate then
			print(humanoid:GetFullName() .. " can no longer auto-rotate!")
			humanoid.AutoRotate = false
		else
			print(humanoid:GetFullName() .. " can now auto-rotate!")
			humanoid.AutoRotate = true
		end
		
		wait(1)
		button.BrickColor = ON_COLOR
		enabled = true
	end
end

local function onTouched(hit)
	local char = hit:FindFirstAncestorWhichIsA("Model")
	if char then
		local humanoid = char:FindFirstChildOfClass("Humanoid")
		if humanoid then
			touchButton(humanoid)
		end
	end
end

button.Touched:Connect(onTouched)
button.BrickColor = ON_COLOR