Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do you tell when a user presses the jump button on mobile?

Asked by 7 years ago
Edited 7 years ago

With the computer it's space, inputObject.KeyCode == Enum.KeyCode.Space, but with mobile I have no clue what it's called.

I've tried other options apart from UserInputService. I've tried the humanoid.Jumping event, and the JumpRequest event of UIS, but both only work when they first jump, but not when they try to jump while in the air, which is what I need.

I also had my friend jump on mobile, open the console, and take a screenshot.

--// Example on computers:
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(inputObject, GPE)
    if ((not GPE) and (inputObject.KeyCode == Enum.KeyCode.Space)) then
        print("Jump Button Pressed!")
    end
end)

Any help would be awesome.

0
Look up ContextActionService and look through the mobile part of the control scripts. Meltdown81 309 — 7y
0
You should make it more obvious that you want a double jump feature ;p RubenKan 3615 — 7y
0
It's a wall jump :P OldPalHappy 1477 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

There are two possible ways to access the JumpButton which is what the user would press to make the character jump on a mobile device.

The first would be to overwrite the existing ControlScript which can be found in the StarterPlayerScripts when running in solo or as a server. This new script will be used when the player join the game instead of the roblox def.

Inside ControlScript->MasterControl->TouchJump on line 156 is where the jump button is connected, simply add your code here to run when the button is pressed:-

JumpButton.InputEnded:connect(function(inputObject)
        if inputObject == touchObject then
            OnInputEnded()
        end
    end)

The second solution would be to find the JumpButton after is is created in the playerGUi e.g. game.Players.LocalPlayer.PlayerGui.TouchGui.TouchControlFrame.JumpButton and connect another Input event to be ran.

I hope this helps.

2
or UserInputService.JumpRequest lmao cabbler 1942 — 7y
Ad

Answer this question