Scripts are like creating your own functions. Basically the script will work as if you had the code from the script in the place where you're calling it from. And yes just like every else the script has to finish executing before the rest of the code can run.
Scripts also have the ability to return values and have values given to them, I'm not sure if you want this much detail but you're gettin' it!
Returning a value works as such:
// adding_script()
return 2 + 2;
That script returns 2 + 2 (4) to the calling code which you can then use like this:
my_number = adding_script();
// my_number now equals 4
You can give values to a script using variables called 'arguments' and they work as such:
// adding_script2()
return argument0 + argument1;
To make this more clear I'll show you how you would call the script:
my_number = adding_script2(2, 2);
// my_number now equals 4
You put in the parentheses the amount of arguments the script needs, the first value is argument0, the second is argument1 and so on (you can have up to 9 arguments).
As another example I'll re-create the function motion_set
// motion_set(direction, speed)
direction = argument0;
speed = argument1;
Hope this helps.