You may use a trigger, which ensures the execution everywhere, and then, inside the script, proceed as your example, if not local, exit. This way the script will be executed only there where the vehicle is local each time (note that locality might change during the game).