There are two things involved here, the binding to the script, and the use if in within the script.
Think of scripts like the built-in functions. If you create a simple binding for Record that will be sent to the currently selected track. If you always want that button to send Record to track number 4, then you have to add that to the binding. This is done with the Send To selector in the binding window. Scripts work the same way, the command will by default be sent to the selected track unless you override that in the binding.
Scripts are different than the built-in functions because they can change the track where commands are sent using the in statement. If you want everything that the script does to happen in track 4, then you could wrap the entire script with an in like this:
#name Rec/Play/Overdub/test/4
in 4 {
if mode equals :Reset
Record
else if mode equals :Record
Overdub
else if mode equals: overdub
Play
else if inPause
Play
else
Stop
}
Note that there is a single in statement wrapping the entire body of the script. You can do that, but if the script only needs to touch one track, it is easier to put the track number in the binding and you won't need to use in.
The other advantage of using bindings is that you can reuse the same Rec/Play/Overdub script for all tracks. The script stays the same, but the binding tells it where to go.