When using ContextActionService and binding an action, the script executives perfectly when just running it in the code, but when under a getPropertyChangeSignal for team change, the function does not execute. I know that this does not have to do with it not firing or something like that; print statements before and after will run, and the buttons show up. It is just that when pressing the button (or using the alternative key for that matter), the function does not run, not even a print statement at the top of the function. I honestly can’t come to an explanation as to why this is happening. Here is the code with the getPropertyChangeSignal:
player:GetPropertyChangedSignal("TeamColor"):Connect(function()
print("Loaded")
if player.TeamColor == BrickColor.new("White") then
ContextActionService:UnbindAction(ACTION_ATTACK)
print("unbound")
elseif player.TeamColor == BrickColor.new("Cyan") then
ContextActionService:BindAction(ACTION_ATTACK, handleAction, true, Enum.UserInputType.MouseButton1)
ContextActionService:BindAction(ACTION_SPRINT, handleAction, true, Enum.KeyCode.R)
end
end)