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

How do I use the Mobile button?

Asked by 6 years ago
Edited 6 years ago

I'm using this code but, instead of using the Mobile Button it creates a new Button to use, how can I use the Mobile Button? the one of the left that walks and the one of the right that jumps?

1local CAS = game:GetService("ContextActionService")
2 
3function OnButtonPress()
4    print('Input W')
5end
6local m = CAS:BindAction("OnButtonPress",OnButtonPress,true,Enum.KeyCode.W)

1 answer

Log in to vote
1
Answered by 6 years ago

In order to manipulate the built in ROBLOX mobile buttons, you need to find them in the player's guis. From there you can check for input and do what you need.

01if Player.PlayerGui:FindFirstChild("TouchGui") then--Check if the player is mobile
02    local JumpButton = Player.PlayerGui.TouchGui:WaitForChild("TouchControlFrame"):WaitForChild("JumpButton")
03    JumpButton.InputBegan:Connect(function(inputobject)
04        if inputobject.UserInputType == Enum.UserInputType.Touch then
05            --Whatever you want to happen when the player touches the jump button
06        end
07    end)
08    JumpButton.InputEnded:Connect(function(inputobject)
09        if inputobject.UserInputType == Enum.UserInputType.Touch then  
10            --Whatever you want to happen when the player stops touching the jump button
11        end
12    end)
13end
Ad

Answer this question