Reverse movement lock

Please help me make sure that the object does not move backwards. Here are excerpts from my script responsible for this. (Script not mine)

-- SETTINGS HERE:
local MaxSpeed = 160
local MaxBackwardsSpeed = 0 -- if we are going backwards this will be our max speed. Set to 0 if players should be unable to drive backwards
local Torque = 9200 -- Motor force/how strong motors are/acceleration speed (the faster you are the smaller it is)
local BrakeTorque = 6700 -- Is always same torque value, should be smaller so tram wont break as fast
local AccelerationLinearFix1 = -100
local AccelerationLinearFix = 1.25 -- DO NOT TOUCH IF YOU DONT UNDERSTAND: This value should start from 1 and the bigger it is the more non linear acceleration is (depending on speed)
-- Settings end here, below is script itself -----------------------------------------------------------
-- DriveLoop that is used to control driving itself
local DriveLoopEnabled = false
function DriveLoop() -- This loop only works when someome is driving this, otherwise it stops
	if DriveLoopEnabled == false then
		spawn(function()
			DriveLoopEnabled = true

			while wait() do
				local CurrentDriveSeatThrottle = CurrentlyUsedDriveSeat.Throttle
				local CurrentSpeed = CurrentlyUsedDriveSeat.Velocity.Magnitude
				local MoveDirection = math.sign(LMotors[1].Attachment1.WorldAxis:Dot(LMotors[1].Attachment1.Parent.RotVelocity) * CurrentDriveSeatMultiplier)


				local GoalTorque -- Reperesents what torque motors will have after all manipulations that we do below
				if MoveDirection == CurrentDriveSeatThrottle then -- We accelerate in any direction (move direction 1, throttle 1 OR move direction -1, throttle -1)
					local CurrentSpeedPercentage
					if CurrentDriveSeatThrottle > 0 then -- Going forwards
						CurrentSpeedPercentage = 1-((CurrentSpeed/MaxSpeed)^AccelerationLinearFix)
					else -- Going backwards
						GoalTorque = 1-((CurrentSpeed/MaxBackwardsSpeed)^AccelerationLinearFix1)
					end

					GoalTorque = Torque * CurrentSpeedPercentage
				else
					GoalTorque = BrakeTorque
				end


				-- Applying to motors
				for i,Motor in pairs(LMotors) do
					Motor.MotorMaxTorque = GoalTorque * math.abs(CurrentDriveSeatThrottle)
					Motor.AngularVelocity = MaxSpeed * CurrentDriveSeatThrottle * CurrentDriveSeatMultiplier
				end
				for i,Motor in pairs(RMotors) do
					Motor.MotorMaxTorque = GoalTorque * math.abs(CurrentDriveSeatThrottle)
					Motor.AngularVelocity = MaxSpeed * -CurrentDriveSeatThrottle * CurrentDriveSeatMultiplier
				end

				-- Stopping the loop in case if its not needed
				if CurrentDriveSeatThrottle == 0 then
					break
				end
			end

			DriveLoopEnabled = false
		end)
	end
end