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

AutoJumpEnabled

Player

bool

The AutoJumpEnabled property determines whether the Player/Character of a Player using a mobile device will automatically jump when they hit an obstacle. This can make levels more navigable while on a mobile device.

When the player joins the game, the StarterPlayer/AutoJumpEnabled value determines the initial state of this property. Then, this property determines the value of the Humanoid/AutoJumpEnabled property of the Player/Characters Humanoid on spawn. In other words, it is possible to set the auto-jump behavior on a per-character, per-player and per-game basis using these three properties.


Code Samples


Auto-Jump Toggle

This code sample is meant for a TextButton. It allows the player to toggle the auto-jumping behavior while on a mobile device.

local player = game.Players.LocalPlayer
local button = script.Parent

local function update()
	-- Update button text
	if player.AutoJumpEnabled then
		button.Text = "Auto-Jump is ON"
	else
		button.Text = "Auto-Jump is OFF"
	end
	-- Reflect the property in the player's character, if they have one
	if player.Character then
		local human = player.Character:FindFirstChild("Humanoid")
		if human then
			human.AutoJumpEnabled = player.AutoJumpEnabled
		end
	end
end

local function onActivated()
	-- Toggle auto-jump
	player.AutoJumpEnabled = not player.AutoJumpEnabled
	-- Update everything else
	update()
end
button.Activated:connect(onActivated)
update()