Greetings! I made it so on Mac, if you double press space, you will start flying as seen in the code below.
How would I add this to iPhone and iPad? The jump button is CoreGUI so it is a lot harder to track it. I looked into Humanoid.Jumping
, but it doesn’t fire when you press the jump button, only when you actually start jumping and hit the floor. Humanoid.Jump
does the same thing.
Is it possible to track when the user presses the Jump button on an iPhone or iPad? Thank you!
local UserInputService = game:GetService("UserInputService")
local DoubleTapThreshold = 0.3
local LastKeyPressTime = 0
UserInputService.InputBegan:Connect(function(key, gameProcessed)
if gameProcessed then return end
if key.KeyCode == KeyCode then
local currentTime = tick()
if currentTime - LastKeyPressTime <= DoubleTapThreshold then
-- This is where I handle flying..
end
LastKeyPressTime = currentTime
end
end)