Code not working

Hello, so I’m trying to make the vehicles in the emergency class have a different speed limit than the other cars, I have tried to do this, but it’s not working:

Citizen.CreateThread( function()
	while true do 
		Citizen.Wait( 0 )   
		local ped = GetPlayerPed(-1)
		local vehicle = GetVehiclePedIsIn(ped, false)
		local speed = GetEntitySpeed(vehicle)
		local emerg = GetVehicleClass(vehicle)
			if ( ped ) then
				if math.floor(speed*1.8) == 120 then
					cruise = GetEntitySpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false))
					if emerg == emergency then
						if math.floor(speed*3.0) == 170 then
						SetEntityMaxSpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false), cruise)
						end
					else
					SetEntityMaxSpeed(GetVehiclePedIsIn(GetPlayerPed(-1), false), cruise)
					end
				end
			end
		end
end)

GetVehicleClass returnes an Int, use emerg == 18 instead see natives

Thank you, But for some reason, Emergency vehicles doesn’t have a speed limit anymore