ContextActionService detect mobile jump button?

How can I detect the when the player pressed the mobile jump button?
I never used ContextActionService before and I have a simple double jump mechanic with climbing.

My code:

function JumpDetect()
	print('r')
	if doubleJumped then
		onJumpRequest()
	end
end

cas:BindAction("JumpDetect", JumpDetect, false, Enum.KeyCode.Space, Enum.KeyCode.ButtonA)

EDIT: I do not want to use JumpRequest because low debounce time doesnn’t work on it.

You can use UserInputService.JumpRequest for this:


local UserInputService = game:GetService("UserInputService")

UserInputService.JumpRequest:Connect(function()
	
end)

I edited my post, sorry I did not want to use JumpRequest cause I want to detect every time the player clicks the jump button on a device

You could useContextActionService so you know when the player jumps. After you can set Humanoid.Sit = false

You will most likely need to use WaitForChild

local player = game.Players.LocalPlayer
local jumpButton = player.PlayerGui.TouchGui.TouchControlFrame.JumpButton

jumpButton.Activated:Connect(function()
    print("Jump button pressed")
end)

Warning if Roblox makes any changes in the future to where the jump button is it will most likely break your script

Also this article might help you setup double jump

3 Likes

I will debug with it, works and makes sense thanks