local F=1.3 local u=1.3 script:WaitForChild("\087\104\105\115\116\108\101")script:WaitForChild("\087\104\105\110\101")script:WaitForChild("\066\079\086")for F,u in pairs(car.DriveSeat:GetChildren())do for F,A in pairs(script:GetChildren())do if u.Name==A.Name then u:Stop()wait()u:Destroy()end end end car.DriveSeat.ChildRemoved:connect(function(F)if F.Name=="\083\101\097\116\087\101\108\100"then for F,u in pairs(car.DriveSeat:GetChildren())do for F,A in pairs(script:GetChildren())do if u.Name==A.Name then u:Stop()wait()u:Destroy()end end end end end)if not _Tune.Engine then return end handler:FireServer("\110\101\119\083\111\117\110\100","\087\104\105\115\116\108\101",car.DriveSeat,script.Whistle.SoundId,0,script.Whistle.Volume,true)handler:FireServer("\110\101\119\083\111\117\110\100","\087\104\105\110\101",car.DriveSeat,script.Whine.SoundId,0,script.Whine.Volume,true)handler:FireServer("\110\101\119\083\111\117\110\100","\066\079\086",car.DriveSeat,script.BOV.SoundId,0,script.BOV.Volume,true)handler:FireServer("\112\108\097\121\083\111\117\110\100","\087\104\105\115\116\108\101")handler:FireServer("\112\108\097\121\083\111\117\110\100","\087\104\105\110\101")car.DriveSeat:WaitForChild("\087\104\105\115\116\108\101")car.DriveSeat:WaitForChild("\087\104\105\110\101")car.DriveSeat:WaitForChild("\066\079\086")local A=tick()local l=_Tune.Turbochargers local I=_Tune.Superchargers while wait()do local H=(script.Parent.Values.Boost.Value/(_Tune.T_Boost*l+_Tune.S_Boost*I))*2 local i=(script.Parent.Values.BoostTurbo.Value/(_Tune.T_Boost*l))*2 local o=script.Parent.Values.BoostSuper.Value/(_Tune.S_Boost*I)local Y,D,y,q,n,e=0,0,0,0,0,0 BOVact=math.floor(i*20)if l~=0 then Y=i D=(i/4)*T_Loudness y=(1-(-i/20))*BOV_Pitch q=(-0.5+(i/2)*BOV_Loudness)*(1-script.Parent.Values.Throttle.Value)if BOVact<BOVact2 then if car.DriveSeat.BOV.IsPaused then if FE then handler:FireServer("\112\108\097\121\083\111\117\110\100","\066\079\086")else car.DriveSeat.BOV:Play()end end end if BOVact>=BOVact2 then if FE then handler:FireServer("\115\116\111\112\083\111\117\110\100","\066\079\086")else car.DriveSeat.BOV:Stop()end end else Y,D,y,q=0,0,0,0 end if I~=0 then n=(script.Parent.Values.RPM.Value/_Tune.Redline)*F e=(o/4)*u else n,e=0,0 end handler:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\087\104\105\115\116\108\101",script.Whistle.SoundId,Y,D)handler:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\087\104\105\110\101",script.Whine.SoundId,n,e)handler:FireServer("\117\112\100\097\116\101\083\111\117\110\100","\066\079\086",script.BOV.SoundId,y,q)if tick()-A>=.1 then BOVact2=math.floor(i*20)A=tick()end end
--Supercharger
local Whine_Pitch = 1.3 --max pitch of the whine (not exact so might have to mess with it)
local S_Loudness = 1.3 --volume of the supercharger(s) (not exact volume so you kinda have to experiment with it also)

script:WaitForChild("Whistle")
script:WaitForChild("Whine")
script:WaitForChild("BOV")

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

car.DriveSeat.ChildRemoved:connect(function(child)
	if child.Name == "SeatWeld" then
		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
	end
end)

if not _Tune.Engine then
	return
end
handler:FireServer("newSound", "Whistle", car.DriveSeat, script.Whistle.SoundId, 0, script.Whistle.Volume, true)
handler:FireServer("newSound", "Whine", car.DriveSeat, script.Whine.SoundId, 0, script.Whine.Volume, true)
handler:FireServer("newSound", "BOV", car.DriveSeat, script.BOV.SoundId, 0, script.BOV.Volume, true)
handler:FireServer("playSound", "Whistle")
handler:FireServer("playSound", "Whine")
car.DriveSeat:WaitForChild("Whistle")
car.DriveSeat:WaitForChild("Whine")
car.DriveSeat:WaitForChild("BOV")
local ticc = tick()
local _TCount = _Tune.Turbochargers
local _SCount = _Tune.Superchargers

while wait() do
	local psi = ((script.Parent.Values.Boost.Value / ((_Tune.T_Boost * _TCount) + (_Tune.S_Boost * _SCount))) * 2)
	local tpsi = ((script.Parent.Values.BoostTurbo.Value / (_Tune.T_Boost * _TCount)) * 2)
	local spsi = (script.Parent.Values.BoostSuper.Value / (_Tune.S_Boost * _SCount))
	--(script.Parent.Values.RPM.Value/_Tune.Redline)
	local WP, WV, BP, BV, HP, HV = 0, 0, 0, 0, 0, 0

	BOVact = math.floor(tpsi * 20)
	if _TCount ~= 0 then
		WP = tpsi
		WV = (tpsi / 4) * T_Loudness

		BP = (1 - (-tpsi / 20)) * BOV_Pitch
		BV = ((-0.5 + ((tpsi / 2) * BOV_Loudness)) * (1 - script.Parent.Values.Throttle.Value))

		if BOVact < BOVact2 then
			if car.DriveSeat.BOV.IsPaused then
				if FE then
					handler:FireServer("playSound", "BOV")
				else
					car.DriveSeat.BOV:Play()
				end
			end
		end
		if BOVact >= BOVact2 then
			if FE then
				handler:FireServer("stopSound", "BOV")
			else
				car.DriveSeat.BOV:Stop()
			end
		end
	else
		WP, WV, BP, BV = 0, 0, 0, 0
	end
	if _SCount ~= 0 then
		HP = (script.Parent.Values.RPM.Value / _Tune.Redline) * Whine_Pitch
		HV = (spsi / 4) * S_Loudness
	else
		HP, HV = 0, 0
	end

	handler:FireServer("updateSound", "Whistle", script.Whistle.SoundId, WP, WV)
	handler:FireServer("updateSound", "Whine", script.Whine.SoundId, HP, HV)
	handler:FireServer("updateSound", "BOV", script.BOV.SoundId, BP, BV)

	if (tick() - ticc) >= 0.1 then
		BOVact2 = math.floor(tpsi * 20)
		ticc = tick()
	end
end
