Bind function to mobile jump button

How do i bind a function to the mobile jump button or what is its keycode?

I already looked up jumpRequests but that doesnt give me the input of when a player is holding the button like with inputbegan and inputended. Instead that just fires when the jump button is pressed once.

edit: i tested with getkeyspressed() that the mobile jump button doesnt have a keycode

You can detect when the user starts holding it an when they release it with GuiButton.MouseButton1Down and GuiButton.MouseButton1Up events. This was mentioned here.

Here’s an example.

local Players = game:GetService("Players")
local plr = Players.LocalPlayer

-- All these WaitforChilds might not be necessary.
local jumpButton = plr:WaitForChild("PlayerGui"):WaitForChild("TouchGui"):WaitForChild("TouchControlFrame"):WaitForChild("JumpButton")

local function startedToHold()
    print("User started to hold the jump button.")
end

local function released()
    print("User released the jump button")
end

jumpButton.MouseButton1Down:Connect(startedToHold)
jumpButton.MouseButton1Up:Connect(released)
7 Likes

Unfortunately this doesn’t seem to work on mobile?

EDIT: crap didn’t realize it was a 2 years old post. :skull: Sorry for necro-posting.

2 Likes