script.Parent.Values.Gear.Changed:connect(function()mult=1 if script.Parent.Values.RPM.Value>5000 then shift=.2 end end)function makeTable(f,S,v)local h={}table.insert(h,f)table.insert(h,S)table.insert(h,v)return h end function update(f)for f,S in pairs(f)do if S[2]~=S[1].Pitch then S[1].Pitch=S[2]end if S[3]~=S[1].Volume then S[1].Volume=S[3]end end end local f=0 local S=false local v game["\082\117\110 \083\101\114\118\105\099\101"].Stepped:connect(function()local f=script.Parent.Values.RPM.Value local S={}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 v(S,v)return math.max((S+(v*f)/_Tune.Redline)*on^2+(det*mult)*math.sin(80*tick()),S)end local h=(throt*shift)*redline+(((trm*trmon)*trmmult)*throt)*math.sin(tick()*50)local l=v(SetPitch,SetRev)*on local u=math.max(h*on,0)table.insert(S,makeTable(bike.DriveSeat.Rev,l,u*vol))if workspace.FilteringEnabled then handler:FireServer("\117\112\100\097\116\101\083\111\117\110\100\115",S)else update(S)end end)



script.Parent.Values.Gear.Changed:connect(function()
	mult=1
	if script.Parent.Values.RPM.Value>5000 then shift=.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-.1)
	
	if script.Parent.Values.Throttle.Value <= 0/100 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/100 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 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(bike.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)
