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