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

How do i create a button for roblox mobile users?

Asked by 10 years ago

I want to add a button for people playing my game on their phone or iPad that when you press it down, it makes a boolvalue true, and when you release it, it makes it false. But i dont know how to create roblox mobile buttons, does anybody know how? Thanks!

1 answer

Log in to vote
0
Answered by
SanityMan 239 Moderation Voter
10 years ago

You can create a button for iOS players with the ContextActionService.

You can bind a function to a new mobile button with game:GetService("ContextActionService"):BindActionToInputTypes("YourActionName", yourfunction, true, inputType)

One way to accomplish your true/false wish would be to have a function that simply toggles a value. To do this, you could put something like this in a Script.

local variable = false

function toggle()
if variable == false then
variable = true
else
variable = false
end
end

game:GetService("ContextActionService"):BindActionToInputTypes("Toggle", toggle, true, "q") --The Q part sets the key q to do the same thing as the mobile button does. Change this to your liking.

Hope this helped!

Ad

Answer this question