Positioning ContextActionService mobile buttons

This is actually due to the case where the Mobile Button’s Positions for ContextActionService are strictly chained as an automatic Frame is attached to every action that’s currently binded, and have their createTouchButton parameter set to true

(Button’s Position is UDim2.new(0, 0, 0, 0))

A way to workaround this, is by retrieving the Mobile Button by calling in the GetButton method, which returns back as a ImageButton Instance where you can set the .Parent property to your own Button UI, but just keep in mind that you’ll have to mess around with their .Size & .Position properties to get the desired result that you want

local CAS = game:GetService("ContextActionService")
local Plr = game.Players.LocalPlayer
local PlrGui = Plr:WaitForChild("PlayerGui")
local OtherUI = PlrGui:WaitForChild("MobileButtons")

local function TestFunction()
	print("Yes")
end

CAS:BindAction("Test", TestFunction, true)

local Button = CAS:GetButton("Test")
Button.Parent = OtherUI.Frame

7 Likes