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!
✓ ANSWER ACCEPTED
How do i create a button for roblox mobile users?
1 answer
✓ Accepted answer
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!
This discussion is preserved as it was. New answers, comments, and votes are closed.
