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)
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)
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)