how about one line?
function toggletimescale(%on){cancel($RandomtimescaleSchedule);if(!%on)return;commandtoserver('timescale', "2");schedule(30000, 0, commandtoserver, 'timescale', "0.2");$RandomtimescaleSchedule = schedule(35000, 0, Randomtimescale, 1);}