I have tried multiple ways to make a debounce on jumping but on mobile it does not work since the button disappears when disabling jump and changing jump power to 0. Any help would be greatly appreciated since I can not figure it out.
-- Services
local userInputService = game:GetService("UserInputService")
local players = game:GetService("Players")
-- Local player
local player = players.LocalPlayer
local character = player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Fires when the user tries to jump
local debounce = false
local function Jump()
if debounce == true then
delay(.375,function()
debounce = false
end)
print("Notable")
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
elseif debounce == false then
debounce = true
print("Able")
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end
local function Jump()
if debounce == false then
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
debounce = true
end
wait(.375)
debounce = false
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
userInputService.JumpRequest:Connect(Jump)