Can I detect when the player stops holding the jump button on their device?

I am trying to make a cross-platform gliding system. I’m using JumpRequest() to detect if the user wants to jump, but I cannot figure out how to detect when the reqeust ends.

The reason I need to know this is so I can set a glide variable to false. I need this to be cross-platform so simply using UIS InputEnded would be annoying. This would also not work well on mobile devices where the jump button is hard to access and changes depending on the control scheme.

Is there a way I can detect when the player lifts up on the jump button on their device without using InputEnded?

This is a bit hacky, but you could check the Jump property on the player’s Humanoid. However, you will have to debounce it since it seems to toggle on/off very fast when the first request to jump occurs (if the user is on the ground).

The Jump property is toggled ON directly when JumpRequest is fired. Jump remains ON until the player either stops jump input or the player is in a state where the player can jump again and is still requesting to jump (in which case it is quickly toggled off and back on again).

Here’s an example that relies on a 0.1 second delayed debounce (which might be able to be reduced) by watching the Humanoid Jump property:

local humanoid = script.Parent:WaitForChild("Humanoid")
local tag = 0

humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	local t = tick()
	tag = t
	wait(0.1)
	if (t == tag and not humanoid.Jump) then
		print("Stop jump")
	end
end)
3 Likes

Unfortunately that won’t help me to know if they’re holding their jump button.

It will if you just change the logic a bit. Again, 0.1 delay, which is not ideal:

local humanoid = script.Parent:WaitForChild("Humanoid")
local tag = 0

local isHoldingJumpInput = false

humanoid:GetPropertyChangedSignal("Jump"):Connect(function()
	local t = tick()
	tag = t
	wait(0.1)
	if (t == tag) then
		isHoldingJumpInput = humanoid.Jump
	end
end)

If I were trying to accomplish this, I would just use ContextActionService and bind my own version.

11 Likes

It seems to work. I would use ContextActionService but I’m not sure how I would bind that to the mobile jump controls.

1 Like