Local script cannot detect server changes in changed functions

This is a snippet of a script I know works perfectly fine, because it does print (ended). However, working is not printed despite the fact there are no errors. The value is changed in the server side, and is not being detected by the local side, the script is being placed inside the players backpack


script.Switch.Changed:Connect(function()
	print("Working")
	if script.Switch.Value == false then
		pcall(function()
			for i, v in pairs(attacks:GetChildren()) do
				CAS:UnbindAction(attacks[i].Value)
			end
		end) 
	else
		wait(1)
		print("Reached_2")
		for i, v in pairs(attacks:GetChildren()) do
			CAS:BindAction(attacks[i].Value,handleAction,true,pc[i])
		end
	end
end)

print("Ended")

Are you sure you’re actually changing the right value on the server side? This should work fine.

I guess you will have to change the first line to “script.Changed:Connect(function()” if Switch is not a child of script. If this is not the case I would ask you for the screen shot for the script in explorer for further help.

Hope this helps you, Thankyou.

Thanks for the reponses, but I have figured the issue is that the script cannot load the function fast enough, and so the value switches before the function is made.