Got a link to the script, or rather the original forum post or blog article that introduced it? Those usually contain a lot of extra useful information that's not readily available in the script.
Also, it's preferable to post links to scripts rather than the script itself, for a number of reasons I won't go into, but if you MUST post the code, putting it in code tags makes it more readable and keeps the formatting.
In your parallel process event where you turn the switch off, you need to add Erase Event afterwards. Then if you have a similar event outside that turns the switch on again, you also need to add an Erase Event. Parallel Process events keep looping until you get rid of them or turn them off, and you don't need to be turning the same switch on or off 60 times a second, every second you're on the map.
Can you go into your scripts, and do a global search (control+shift+f) for 22? See if any of the scripts you've added turn up in the list - maybe take a screenshot of the results and post here.