script.Parent.Values.Gear.Changed:connect(function()mult=1 if script.Parent.Values.RPM.Value>5000 then shift=.2 end end)function makeTable(P,l,r)local O={}table.insert(O,P)table.insert(O,l)table.insert(O,r)return O end function update(P)for P,l in pairs(P)do if l[2]~=l[1].Pitch then l[1].Pitch=l[2]end if l[3]~=l[1].Volume then l[1].Volume=l[3]end end end local P=0 local l=false local r game["\082\117\110 \083\101\114\118\105\099\101"].Stepped:connect(function()local P=script.Parent.Values.RPM.Value local l={}mult=math.max(0,mult-.1)if script.Parent.Values.Throttle.Value<=.0 then throt=math.max(.3,throt-.2)else throt=math.min(1,throt+.1)end shift=math.min(1,shift+.2)if script.Parent.Values.RPM.Value>_Tune.Redline-_Tune.RevBounce/4 and script.Parent.Values.Throttle.Value>.0 then redline=.5 else redline=1 end if not script.Parent.IsOn.Value then on=math.max(on-.015,0)else on=1 end local function r(l,r)return math.max((l+(r*P)/_Tune.Redline)*on^2+(det*mult)*math.sin(80*tick()),l)end local O=(throt*shift)*redline+(((trm*trmon)*trmmult)*throt)*math.sin(tick()*50)local v=r(SetPitch,SetRev)*on local S=math.max(O*on,0)table.insert(l,makeTable(car.DriveSeat.Rev,v,S*vol))if workspace.FilteringEnabled then handler:FireServer("\117\112\100\097\116\101\083\111\117\110\100\115",l)else update(l)end end)
--handler:FireServer("playSound",Your sound here)

script.Parent.Values.Gear.Changed:connect(function()
	mult = 1
	if script.Parent.Values.RPM.Value > 5000 then
		shift = 0.2
	end
end)

function makeTable(snd, pit, vol)
	local tbl = {}
	table.insert(tbl, snd)
	table.insert(tbl, pit)
	table.insert(tbl, vol)
	return tbl
end

function update(tbl)
	for _, i in pairs(tbl) do
		if i[2] ~= i[1].Pitch then
			i[1].Pitch = i[2]
		end
		if i[3] ~= i[1].Volume then
			i[1].Volume = i[3]
		end
	end
end

local lt = 0
local start = false
local play
game["Run Service"].Stepped:connect(function()
	local _RPM = script.Parent.Values.RPM.Value
	local updtbl = {}
	mult = math.max(0, mult - 0.1)

	if script.Parent.Values.Throttle.Value <= 0 / 100 then
		throt = math.max(0.3, throt - 0.2)
	else
		throt = math.min(1, throt + 0.1)
	end

	shift = math.min(1, shift + 0.2)

	if
		script.Parent.Values.RPM.Value > _Tune.Redline - _Tune.RevBounce / 4
		and script.Parent.Values.Throttle.Value > 0 / 100
	then
		redline = 0.5
	else
		redline = 1
	end

	if not script.Parent.IsOn.Value then
		on = math.max(on - 0.015, 0)
	else
		on = 1
	end

	local function pitch(pit, rev)
		return math.max(((pit + rev * _RPM / _Tune.Redline) * on ^ 2) + (det * mult * math.sin(80 * tick())), pit)
	end
	local volBase = ((throt * shift * redline) + (trm * trmon * trmmult * throt * math.sin(tick() * 50)))

	local RevP = pitch(SetPitch, SetRev) * on

	local RevV = math.max(volBase * on, 0)

	table.insert(updtbl, makeTable(car.DriveSeat.Rev, RevP, RevV * vol))
	--table.insert(updtbl,makeTable(Your sound here, Pitch here, Volume here))

	if workspace.FilteringEnabled then
		handler:FireServer("updateSounds", updtbl)
	else
		update(updtbl)
	end
end)
