For some reason, when I use ContextAction:GetButton, it returns nil, even though I’ve made the button and I can see it parented in my player gui.
Here’s the code:
ContextAction:BindAction("PBrake", ContextToInput, true)
ContextAction:BindAction("Leave", ContextToInput, true) -- not getting the button for this one...
Then later on…
do -- this one works
local Button = ContextAction:GetButton("PBrake")
Button.Position = UDim2.new(0.9, 0,0.5, 0)
Button.Size = UDim2.new(0.1, 0,0.1, 0)
Button.AnchorPoint = Vector2.new(0.5,0.5)
Button.Parent = script.Parent
local AspectRatio = Instance.new("UIAspectRatioConstraint", Button)
end
do -- The GetButton method returns nil on this one
local Button = ContextAction:GetButton("Leave")
Button.Position = UDim2.new(0.9, 0,0.35, 0)
Button.Size = UDim2.new(0.1, 0,0.1, 0)
Button.AnchorPoint = Vector2.new(0.5,0.5)
Button.Parent = script.Parent
local AspectRatio = Instance.new("UIAspectRatioConstraint", Button)
end
I have no idea why this doesn’t work, but it doesn’t. There are a lot more bindings above this one in the script though. Here’s the full list.
ContextAction:BindAction("Throttle", ContextToInput, true)
ContextAction:BindAction("Brake", ContextToInput, true)
ContextAction:BindAction("SteerLeft", ContextToInput, true)
ContextAction:BindAction("SteerRight", ContextToInput, true)
ContextAction:BindAction("ShiftUp", ContextToInput, true)
ContextAction:BindAction("ShiftDown", ContextToInput, true)
ContextAction:BindAction("PBrake", ContextToInput, true)
ContextAction:BindAction("Leave", ContextToInput, true) -- not getting the button for this one...
Each of those have their own do … end script identical to the ones above. If you guys need the full scripts just DM me I’ll be happy to give them to you.
Edit: Even after I unbind the action, the button on my screen still doesn’t remove.