Question / Help with mobile controls/buttons on Roblox Studio

Hello! I would like to add Mobile Buttons / Controls to My Game!

I would like to add a button which is the equivalent of pressing “Q” on the pc.

Like, with Q on my game you throw a ball of energy, I wish there was a button on mobile that would emulate pressing Q on the keyboard

I hope you can help me

1 Like

Checkout these articles, they’ll help along side you knowing how to work with guis!

2 Likes

The simple way to do it, is to create a button in the UI and have both .Activated and BindAction associated with it to cover both keyboard and touch input:

local function buttonPressed()
	print("Button was pressed")
end
-- Connect to capture both touch and mouse click on UI button
btnPressed.Activated:Connect(function()
	buttonPressed()
end
-- Keybind event to Q
local btnValue = "Q"
ContextActionService:BindAction(btnValue , buttonPressed, true, Enum.KeyCode.Q)

The above rough code caters for both types of interface from users so allows a single common interface. I have been using variations of this to create custom backpacks in recent months with some success

1 Like