JumpRequest isn't working for Mobile

Hi there,

I wanted to make a Jump Cooldown System it works perfect, but not for mobile. When I try to jump on mobile the button disappers and I can’t jump again. How can I fix this to work on all platforms?

local char = script.Parent.Parent
local humanoid = char:WaitForChild("Humanoid")
local config = script.Parent.Configuration
local cooldownTime = config.Cooldown.Value
local canJump = true

local function onJumpRequest()
    if canJump then
        canJump = false
        humanoid.Jump = true
        humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
        task.wait(cooldownTime)
        humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
        canJump = true
    end
end

game:GetService("UserInputService").JumpRequest:Connect(onJumpRequest)
1 Like

Please try this, it should work

local UIS = game:GetService("UserInputService")

local char = script.Parent.Parent
local humanoid = char:WaitForChild("Humanoid")
local config = script.Parent.Configuration
local cooldownTime = config.Cooldown.Value
local canJump = true

local function onJumpRequest()
    if canJump then
        canJump = false
        humanoid.Jump = true
        humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
        task.wait(cooldownTime)
        humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
        canJump = true
    end
end

UIS.JumpRequest:Connect(onJumpRequest)

UIS.TouchTap:Connect(onJumpRequest)
2 Likes

Needed to change it up a bit, still doesn’t work, when I jump on mobile the jumpbutton disappers.

local UIS = game:GetService("UserInputService")

local char = script.Parent.Parent
local humanoid = char:WaitForChild("Humanoid")
local config = script.Parent.Configuration
local cooldownTime = config.Cooldown.Value
local canJump = true

local function onJumpRequest()
    if canJump then
        canJump = false
        humanoid.Jump = true
        humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
        task.wait(cooldownTime)
        humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
        canJump = true
    end
end

UIS.JumpRequest:Connect(onJumpRequest)

UIS.TouchTap:Connect(onJumpRequest)
1 Like

Jump request doesn’t work properly on mobile. I just listen for input on the jump button instead (emulate mobile, player gui —> TouchGui)

So how should I make it right?

1 Like