scrSpeed

This script will change the speed of an object until it reaches the desired speed

 Script

/// Speed Change
/* changes the speed to a certain speed when given several variables
to use this apply values to these variables:
sp = (boolean) 
    enables/disables the script
sp_val = (double)
    the final speed of the object
sp_dev = (double)
    the rate at which the object goes to sp_val
*/
if (sp) {

    var flag = false;
    var inc = abs(sp_dev);

    if (sp_val < 0) { // if negative
        if (speed < sp_val) {
            speed += inc;
            if (speed >= sp_val) {
                flag = true;
            }
        } else {
            speed -= inc;
            if (speed <= sp_val) {
                flag = true;
            }
        }
    } else { // else do positive
        if (speed < sp_val) {
            speed += inc;
            if (speed >= sp_val) {
                flag = true;
            }
        } else {
            speed -= inc;
            if (speed <= sp_val) {
                flag = true;
            }
        }
    }
    if (flag) {
        speed = sp_val;
        sp = false;
    }
}