How does :SetPosition work?

I’m trying to position my TouchButtons correctly using ContextActionService:SetPosition and it doesn’t seem to be working correctly?

ContextActionService:SetPosition("ActionName", UDim2.new(.5,0,.5,0))

I figured if I set the position to be in the center of the screen the button would be there, but the button ends up being on top of the jump button.

The position set for the button is actually relative to UDim2(0.7,0,0.5,0)

This is because the button is parented to a frame created by the ContextActionTouch CoreScript.

Here is where the frame for ContextActionService buttons is created:

1 Like

Thanks! Also I noticed that :UnbindAction() has a chance of not removing touchButtons if they were edited manually, if I wanted to get rid of them would I used :GetButton() and :Destroy()?

Is this the case? It sounds like something that should be fixed.

Says so on the Wiki

http://wiki.roblox.com/index.php?title=API:Class/ContextActionService/UnbindAction

Manipulating the button means getting the button with GetButton and then doing some re-parenting or something. If you only use the ContextActionService methods to change the button then it will be removed when the action is unbound.

1 Like