local p=workspace.FilteringEnabled local n=script.Parent.Car.Value local T=n:WaitForChild("\065\067\054\095\070\069\095\083\111\117\110\100\115\077\105\115\099")local y=require(n["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local x=0 local V=0 local b=.13 script:WaitForChild("\082\101\108")script:WaitForChild("\083\116\097\114\116")script.Parent.Values.Gear.Changed:connect(function()V=1 end)for p,n in pairs(n.DriveSeat:GetChildren())do for p,T in pairs(script:GetChildren())do if n.Name==T.Name then n:Stop()wait()n:Destroy()end end end T:FireServer("\110\101\119\083\111\117\110\100","\082\101\108",n.DriveSeat,script.Rel.SoundId,0,script.Rel.Volume,true)T:FireServer("\110\101\119\083\111\117\110\100","\083\116\097\114\116",n.DriveSeat,script.Start.SoundId,1,script.Start.Volume,false)T:FireServer("\112\108\097\121\083\111\117\110\100","\082\101\108")n.DriveSeat:WaitForChild("\082\101\108")n.DriveSeat:WaitForChild("\083\116\097\114\116")while wait()do V=math.max(0,V-.1)local F=script.Parent.Values.RPM.Value if script.Parent.Values.PreOn.Value then T:FireServer("\112\108\097\121\083\111\117\110\100","\083\116\097\114\116")wait(3.4)else if not script.Parent.IsOn.Value then x=math.max(x-.015,0)else x=1 end RelVolume=3*(1-math.min((script.Parent.Values.RPM.Value*3)/y.Redline,1))RelPitch=math.max((script.Rel.SetPitch.Value+(script.Rel.SetRev.Value*F)/y.Redline)*x^2+(b*V)*math.sin(80*tick()),script.Rel.SetPitch.Value)*x end if p then T:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\082\101\108",script.Rel.SoundId,RelPitch,RelVolume)else n.DriveSeat.Rel.Volume=RelVolume n.DriveSeat.Rel.Pitch=RelPitch end end

local FE = workspace.FilteringEnabled
local car = script.Parent.Car.Value
local handler = car:WaitForChild("AC6_FE_SoundsMisc")
local _Tune = require(car["A-Chassis Tune"])
local on = 0
local mult=0
local det=.13

script:WaitForChild("Rel")
script:WaitForChild("Start")

script.Parent.Values.Gear.Changed:connect(function() mult=1 end)

for i,v in pairs(car.DriveSeat:GetChildren()) do
	for _,a in pairs(script:GetChildren()) do
		if v.Name==a.Name then v:Stop() wait() v:Destroy() end
	end
end

handler:FireServer("newSound","Rel",car.DriveSeat,script.Rel.SoundId,0,script.Rel.Volume,true)
handler:FireServer("newSound","Start",car.DriveSeat,script.Start.SoundId,1,script.Start.Volume,false)
handler:FireServer("playSound","Rel")
car.DriveSeat:WaitForChild("Rel")
car.DriveSeat:WaitForChild("Start")

while wait() do
	mult=math.max(0,mult-.1)
	local _RPM = script.Parent.Values.RPM.Value
	if script.Parent.Values.PreOn.Value then
		handler:FireServer("playSound","Start")
		wait(3.4)
	else
		if not script.Parent.IsOn.Value then on=math.max(on-.015,0) else on=1 end
		RelVolume = 3*(1 - math.min(((script.Parent.Values.RPM.Value*3)/_Tune.Redline),1))
		RelPitch = (math.max((((script.Rel.SetPitch.Value + script.Rel.SetRev.Value*_RPM/_Tune.Redline))*on^2)+(det*mult*math.sin(80*tick())),script.Rel.SetPitch.Value)) * on
	end
	if FE then
		handler:FireServer("updateSound","Rel",script.Rel.SoundId,RelPitch,RelVolume)
	else
		car.DriveSeat.Rel.Volume = RelVolume
		car.DriveSeat.Rel.Pitch = RelPitch
	end
end
