How do I achieve this type of engine SFX for my vehicle?

I need to know what math to use to make my engine sound based on the cars gear and speed

let’s say it’s on gear 2, and it just transmission to gear 2. the engine would be low sound. when it’s at the near end of gear 2, it’ll be higher sound. when it reaches gear 3, the cycle repeats.

gears all have a speed value that determines what speed the car has to be to switch to the next gear. It works fine but the SFX I’m not sure about.

how can I do that?

If you use the car’s speed as part of the equation you can change the PlaybackSpeed.
I use this formula for a single speed in my boat, but you could use a multiplier (say 1 for first gear, 0.7 for 2nd, 0.5 for 3rd etc.)

	speed = (script.Parent.Velocity.Magnitude)
	sound.PlaybackSpeed =  math.clamp((multiplier * speed/12), .7, 1.3) -- change the numbers to works for you, the min is idle, the max is full rpm.