ContextActionService SetPosition Function Not Working As Intended

Hello, :wave:

I made a button it works fine, but for mobile. The button overlaps the jump button. So, I tried changing the position of it using the :SetPosition() function but the button won’t change position. Thanks! :wave:

2 Likes

Script? Errors? Bombs? :thinking:

No errors, it just like won’t change position.

Did you set the UDim2 correctly? Or did you name your actionName variable wrong?

Nope. I set both of them correct.

I don’t know what I did wrong. Could it be that it’s broken?

first get the button is what it says
and set its position

It won’t work.

local cas = game:GetService("ContextActionService")



local function m()
	
	print("Hi")
	
	cas:UnbindAction("B")
	
end



cas:BindAction("B", m, true, Enum.KeyCode.X)

cas:SetPosition("B", UDim2.new(9.1, 0, 8.5, 0))

:+1:
is that all of the code?

userinputService=game:GetService("UserInputService")
local cas = game:GetService("ContextActionService")

local function m(actionName, inputState, inputObject)
    if actionName == "action" then
        if inputState == Enum.UserInputState.Begin then
            print("Hi")
        else

        end
    end
end

cas:BindAction("action", m, true, Enum.KeyCode.X)
userinputService.InputBegan:Connect(function()
    local btn=cas:GetButton("action")
    btn:SetPosition(UDim2.new(0,0,0,0))
end)

does this work

Would you mind stop sending links of the api. I’ve already read it a bunch of times.

Yes. I just made something simple to check if the function’ll work.

Your script should be a LocalScript parented inside 1 of the local descendant areas if I’m not mistaken, correct?

It’s already a local script, I placed it in starterplayerscripts.

I’m getting the same problem. There’s several other context buttons where SetPosition and SetTitle work fine, but for some reason just one is not being affected by either function.

3 Likes

having the same problem as well