Many locos and trains have a lower speed limit than the track speed limits. The only script that I had seen would apply the emergency brakes if you went over the limit, and eventually end the scenario. Applying the emergency brake and stopping the train can lead to timing problems and interaction with AI later in the scenario.

My script gives a warning notice to slow down

If you fail to slow down then a larger notice appears that will stay on screen until you have slowed to the limit

After a set number of offences the brakes are applied, and the throttle plus reverser are closed. You don't need to stop and can react by releasing the brake and engaging the reverser and throttle immediately - but by that time you will have slowed by quite a lot.

Every time you speed after that the brakes will be applied.
At no time are you bought to a compulsory stop, and the scenario is not ended by repeat infringements

Full instructions on making adjustments to speed settings and number of warnings given, and installing into your own scenarios, along with a test scenario are included in the package which is available from: