BindAction with ContextActionService doesn't run function when put under getpropertychangesignal

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)
1 Like

So I just realized that since this is a local script and that the team in this game changes only when the player dies, I could just use an if statement since the local script will be reloaded anyways. Did this and it works. But since I feel like this should still work, my same question remains: why does this not work with the getPropertyChangeSignal if the signal fires? Is this a bug?

1 Like