I was making a script that would disable the player from moving whenever they touched a part. I tested the script, and it works, but whenever I disable the script it doesn't run whenever I touch the part.
Here is the script for disabling walking:
while true do
wait()
local movement = game:GetService("ContextActionService")
movement:UnbindAction("backwardMovement")
movement:UnbindAction("leftMovement")
movement:UnbindAction("rightMovement")
movement:UnbindAction("forwardMovement")
end
And the script inside the part:
script.Parent.Touched:connect(function()
game.StarterPlayer.StarterCharacterScripts.Nowalk.Disabled = false
end)
If you have any ideas please let me know. I'm new to scripting, so please explain what I did wrong.

3 comments
As a note first, I think the while loop is unneeded. Once unbinded, I don't believe CAS auto-rebinds your movement :P As for your problem, is your game filtering enabled?
I tried switching the filtering on and off, it didn't seem to work for either one :/
When the script disabled, it is not supposed to run unless you have another script which will enable it in game.