Help with some fun math code

Hey devs, I’m looking to figure out how to make it that a script will automatically stop a car when a player exits the car. This is my script for far:

local seat = script.Parent
wheel1 = script.Parent.Parent.Parent.WheelBL.Wheel.Hub 
wheel2 = script.Parent.Parent.Parent.WheelBR.Wheel.Hub
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	if seat.Occupant then
		print("Driver in car")
	else
		print("No driver")
		while true do
			wait (0.1)
			local wlsp = (wheel2.RotVelocity)
			print(wlsp)
			if wlsp <= 0.005 then
				seat.Throttle = -1
			end
	end
	end
end)

When I run the game, it gives me the error “Workspace.Car.Base.VehicleSeat.BrakeOnExit:13: attempt to compare Vector3 <= number”. Anyone know what is happening and how to fix it?

https://developer.roblox.com/en-us/api-reference/property/VehicleSeat/MaxSpeed

You could make use of the MaxSpeed property to achieve this. Unless the speed of the vehicle is handled in some other way.

wlsp is a Vector3 value (RotVelocity), and you can’t compare Vector3 values with numbers. In other words, the computer doesn’t understand “wlsp <= 0.005”.

All Vector3 values have a magnitude, though, which is basically the overall size, length, or strength of the value. To access this, you can write Vector3Value.Magnitude. In your case, this would be:

local wlsp = wheel2.RotVelocity.Magnitude