-
I want that when the player press the space button, or jump button in case of mobile users it double jump
-
This is just a part of the complete script
local function onInputBegan(input, gameProcessedEvent)
if gameProcessedEvent or not (input.UserInputType == Enum.UserInputType.Keyboard or input.UserInputType == Enum.UserInputType.Touch) then
return
end
if input.UserInputType == Enum.UserInputType.Keyboard and input.KeyCode == Enum.KeyCode.Space or
input.UserInputType == Enum.UserInputType.Touch and input.KeyCode == Enum.KeyCode.ButtonA then
local now = tick()
if now - lastJumpTime < 0.75 and stamina >= 20 then -- double jump
Character:FindFirstChildOfClass("Humanoid"):ChangeState(Enum.HumanoidStateType.Jumping)
doubleJumpTrack:Play()
stamina = stamina - 15
updateStaminaBar()
end
end
end
- Is supposed to work for desktop and mobile, but only works for desktop users.
Thanks for reading