if autoscaling then local r={}if _Tune.Config=="\070\087\068"or _Tune.Config=="\065\087\068"then if car.Wheels:FindFirstChild("\070\076")~=nil then table.insert(r,car.Wheels.FL)end if car.Wheels:FindFirstChild("\070\082")~=nil then table.insert(r,car.Wheels.FR)end if car.Wheels:FindFirstChild("\070")~=nil then table.insert(r,car.Wheels.F)end end if _Tune.Config=="\082\087\068"or _Tune.Config=="\065\087\068"then if car.Wheels:FindFirstChild("\082\076")~=nil then table.insert(r,car.Wheels.RL)end if car.Wheels:FindFirstChild("\082\082")~=nil then table.insert(r,car.Wheels.RR)end if car.Wheels:FindFirstChild("\082")~=nil then table.insert(r,car.Wheels.R)end end local f=0 for r,a in pairs(r)do if a.Size.x>f then f=a.Size.x end end r=nil for r,a in pairs(UNITS)do a.maxSpeed=math.ceil(((((((a.scaling*f)*math.pi)*_lRPM)/60)/_Tune.Ratios[#_Tune.Ratios])/_Tune.FinalDrive)/_Tune.FDMult)a.spInc=math.max(math.ceil(a.maxSpeed/150)*10,10)end end for r=0,revEnd*2,1 do local f=gauges.ln:clone()f.Parent=gauges.Tach f.Rotation=45+(r*225)/(revEnd*2)f.Num.Text=r/2 f.Num.Rotation=-f.Rotation if r*500>=math.floor(_pRPM/500)*500 then f.Frame.BackgroundColor3=Color3.new(1,0,0)if r<revEnd*2 then ln2=f:clone()ln2.Parent=gauges.Tach ln2.Rotation=45+((r+.5)*225)/(revEnd*2)ln2.Num:Destroy()ln2.Visible=true end end if r%2==0 then f.Frame.Size=UDim2.new(0,3,0,10)f.Frame.Position=UDim2.new(0,-1,0,100)f.Num.Visible=true else f.Num:Destroy()end f.Visible=true end local r=Instance.new("\070\114\097\109\101",gauges.Speedo)r.Name="\108\110\115"r.BackgroundTransparency=1 r.BorderSizePixel=0 r.Size=UDim2.new(0,0,0,0)for f=1,90,1 do local a=gauges.ln:clone()a.Parent=r a.Rotation=45+225*(f/90)if f%2==0 then a.Frame.Size=UDim2.new(0,2,0,10)a.Frame.Position=UDim2.new(0,-1,0,100)else a.Frame.Size=UDim2.new(0,3,0,5)end a.Num:Destroy()a.Visible=true end local f=Instance.new("\070\114\097\109\101",gauges.Boost)f.Name="\098\108\110\115"f.BackgroundTransparency=1 f.BorderSizePixel=0 f.Size=UDim2.new(0,0,0,0)for r=0,12,1 do local a=gauges.bln:clone()a.Parent=f a.Rotation=45+270*(r/12)if r%2==0 then a.Frame.Size=UDim2.new(0,2,0,7)a.Frame.Position=UDim2.new(0,-1,0,40)else a.Frame.Size=UDim2.new(0,3,0,5)end a.Num:Destroy()a.Visible=true end for r,f in pairs(UNITS)do local a=Instance.new("\070\114\097\109\101",gauges.Speedo)a.BackgroundTransparency=1 a.BorderSizePixel=0 a.Size=UDim2.new(0,0,0,0)a.Name=f.units if r~=1 then a.Visible=false end for r=0,f.maxSpeed,f.spInc do local m=gauges.ln:clone()m.Parent=a m.Rotation=45+225*(r/f.maxSpeed)m.Num.Text=r m.Num.TextSize=14 m.Num.Rotation=-m.Rotation m.Frame:Destroy()m.Num.Visible=true m.Visible=true end end if isOn.Value then gauges:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)end isOn.Changed:connect(function()if isOn.Value then gauges:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)end end)values.RPM.Changed:connect(function()gauges.Tach.Needle.Rotation=45+225*math.min(1,values.RPM.Value/(revEnd*1000))end)local a=0 if _Tune.Aspiration~="\078\097\116\117\114\097\108"and _Tune.Engine then if _Tune.Aspiration=="\083\105\110\103\108\101"or _Tune.Aspiration=="\083\117\112\101\114"then a=1 elseif _Tune.Aspiration=="\068\111\117\098\108\101"then a=2 end values.Boost.Changed:connect(function()local r=math.floor(values.Boost.Value)if _Tune.Aspiration~="\083\117\112\101\114"then r=math.floor(values.Boost.Value)*1.2-(_Tune.Boost*a)/5 end gauges.Boost.Needle.Rotation=45+270*math.min(1,(values.Boost.Value/_Tune.Boost)/a)gauges.PSI.Text=tostring(math.floor(r).." \080\083\073")end)else gauges.Boost:Destroy()end values.Gear.Changed:connect(function()local r=values.Gear.Value if r==0 then r="\078"elseif r==-1 then r="\082"end gauges.Gear.Text=r end)values.TCS.Changed:connect(function()if _Tune.TCSEnabled then if values.TCS.Value then gauges.TCS.TextColor3=Color3.new(1,.66666666666667,0)gauges.TCS.TextStrokeColor3=Color3.new(1,.66666666666667,0)if values.TCSActive.Value then wait()gauges.TCS.Visible=not gauges.TCS.Visible else wait()gauges.TCS.Visible=false end else gauges.TCS.Visible=true gauges.TCS.TextColor3=Color3.new(1,0,0)gauges.TCS.TextStrokeColor3=Color3.new(1,0,0)end else gauges.TCS.Visible=false end end)values.TCSActive.Changed:connect(function()if _Tune.TCSEnabled then if values.TCSActive.Value and values.TCS.Value then wait()gauges.TCS.Visible=not gauges.TCS.Visible elseif not values.TCS.Value then wait()gauges.TCS.Visible=true else wait()gauges.TCS.Visible=false end else gauges.TCS.Visible=false end end)gauges.TCS.Changed:connect(function()if _Tune.TCSEnabled then if values.TCSActive.Value and values.TCS.Value then wait()gauges.TCS.Visible=not gauges.TCS.Visible elseif not values.TCS.Value then wait()gauges.TCS.Visible=true end else if gauges.TCS.Visible then gauges.TCS.Visible=false end end end)values.ABS.Changed:connect(function()if _Tune.ABSEnabled then if values.ABS.Value then gauges.ABS.TextColor3=Color3.new(1,.66666666666667,0)gauges.ABS.TextStrokeColor3=Color3.new(1,.66666666666667,0)if values.ABSActive.Value then wait()gauges.ABS.Visible=not gauges.ABS.Visible else wait()gauges.ABS.Visible=false end else gauges.ABS.Visible=true gauges.ABS.TextColor3=Color3.new(1,0,0)gauges.ABS.TextStrokeColor3=Color3.new(1,0,0)end else gauges.ABS.Visible=false end end)values.ABSActive.Changed:connect(function()if _Tune.ABSEnabled then if values.ABSActive.Value and values.ABS.Value then wait()gauges.ABS.Visible=not gauges.ABS.Visible elseif not values.ABS.Value then wait()gauges.ABS.Visible=true else wait()gauges.ABS.Visible=false end else gauges.ABS.Visible=false end end)gauges.ABS.Changed:connect(function()if _Tune.ABSEnabled then if values.ABSActive.Value and values.ABS.Value then wait()gauges.ABS.Visible=not gauges.ABS.Visible elseif not values.ABS.Value then wait()gauges.ABS.Visible=true end else if gauges.ABS.Visible then gauges.ABS.Visible=false end end end)function PBrake()gauges.PBrake.Visible=values.PBrake.Value end values.PBrake.Changed:connect(PBrake)function Gear()if values.TransmissionMode.Value=="\065\117\116\111"then gauges.TMode.Text="\065\047\084"gauges.TMode.BackgroundColor3=Color3.new(1,.66666666666667,0)elseif values.TransmissionMode.Value=="\083\101\109\105"then gauges.TMode.Text="\083\047\084"gauges.TMode.BackgroundColor3=Color3.new(0,.66666666666667,.49803921568627)else gauges.TMode.Text="\077\047\084"gauges.TMode.BackgroundColor3=Color3.new(1,.33333333333333,.5)end end values.TransmissionMode.Changed:connect(Gear)values.Velocity.Changed:connect(function(r)gauges.Speedo.Needle.Rotation=45+225*math.min(1,(UNITS[currentUnits].scaling*values.Velocity.Value.Magnitude)/UNITS[currentUnits].maxSpeed)gauges.Speed.Text=math.floor(UNITS[currentUnits].scaling*values.Velocity.Value.Magnitude)..(" "..UNITS[currentUnits].units)end)gauges.Speed.MouseButton1Click:connect(function()if currentUnits==#UNITS then currentUnits=1 else currentUnits=currentUnits+1 end for r,f in pairs(gauges.Speedo:GetChildren())do f.Visible=f.Name==UNITS[currentUnits].units or f.Name=="\078\101\101\100\108\101"or f.Name=="\108\110\115"end gauges.Speed.Text=math.floor(UNITS[currentUnits].scaling*values.Velocity.Value.Magnitude)..(" "..UNITS[currentUnits].units)end)wait(.1)Gear()PBrake()

if autoscaling then
	local Drive={}
	if _Tune.Config == "FWD" or _Tune.Config == "AWD" then
		if car.Wheels:FindFirstChild("FL")~= nil then
			table.insert(Drive,car.Wheels.FL)
		end
		if car.Wheels:FindFirstChild("FR")~= nil then
			table.insert(Drive,car.Wheels.FR)
		end
		if car.Wheels:FindFirstChild("F")~= nil then
			table.insert(Drive,car.Wheels.F)
		end
	end
	if _Tune.Config == "RWD" or _Tune.Config == "AWD" then
		if car.Wheels:FindFirstChild("RL")~= nil then
			table.insert(Drive,car.Wheels.RL)
		end
		if car.Wheels:FindFirstChild("RR")~= nil then
			table.insert(Drive,car.Wheels.RR)
		end
		if car.Wheels:FindFirstChild("R")~= nil then
			table.insert(Drive,car.Wheels.R)
		end
	end

	local wDia = 0
	for i,v in pairs(Drive) do
		if v.Size.x>wDia then wDia = v.Size.x end
	end
	Drive = nil
	for i,v in pairs(UNITS) do
		v.maxSpeed = math.ceil(v.scaling*wDia*math.pi*_lRPM/60/_Tune.Ratios[#_Tune.Ratios]/_Tune.FinalDrive/_Tune.FDMult)
		v.spInc = math.max(math.ceil(v.maxSpeed/150)*10,10)
	end
end

for i=0,revEnd*2 do
	local ln = gauges.ln:clone()
	ln.Parent = gauges.Tach
	ln.Rotation = 45 + i * 225 / (revEnd*2)
	ln.Num.Text = i/2
	ln.Num.Rotation = -ln.Rotation
	if i*500>=math.floor(_pRPM/500)*500 then
		ln.Frame.BackgroundColor3 = Color3.new(1,0,0)
		if i<revEnd*2 then
			ln2 = ln:clone()
			ln2.Parent = gauges.Tach
			ln2.Rotation = 45 + (i+.5) * 225 / (revEnd*2)
			ln2.Num:Destroy()
			ln2.Visible=true
		end
	end
	if i%2==0 then
		ln.Frame.Size = UDim2.new(0,3,0,10)
		ln.Frame.Position = UDim2.new(0,-1,0,100)
		ln.Num.Visible = true
	else
		ln.Num:Destroy()
	end
	ln.Visible=true
end

local lns = Instance.new("Frame",gauges.Speedo)
lns.Name = "lns"
lns.BackgroundTransparency = 1
lns.BorderSizePixel = 0
lns.Size = UDim2.new(0,0,0,0)
for i=1,90 do
	local ln = gauges.ln:clone()
	ln.Parent = lns
	ln.Rotation = 45 + 225*(i/90)
	if i%2==0 then
		ln.Frame.Size = UDim2.new(0,2,0,10)
		ln.Frame.Position = UDim2.new(0,-1,0,100)
	else
		ln.Frame.Size = UDim2.new(0,3,0,5)
	end
	ln.Num:Destroy()
	ln.Visible=true
end

local blns = Instance.new("Frame",gauges.Boost)
blns.Name = "blns"
blns.BackgroundTransparency = 1
blns.BorderSizePixel = 0
blns.Size = UDim2.new(0,0,0,0)
for i=0,12 do
	local bln = gauges.bln:clone()
	bln.Parent = blns
	bln.Rotation = 45+270*(i/12)
	if i%2==0 then
		bln.Frame.Size = UDim2.new(0,2,0,7)
		bln.Frame.Position = UDim2.new(0,-1,0,40)
	else
		bln.Frame.Size = UDim2.new(0,3,0,5)
	end
	bln.Num:Destroy()
	bln.Visible=true
end

for i,v in pairs(UNITS) do
	local lnn = Instance.new("Frame",gauges.Speedo)
	lnn.BackgroundTransparency = 1
	lnn.BorderSizePixel = 0
	lnn.Size = UDim2.new(0,0,0,0)
	lnn.Name = v.units
	if i~= 1 then lnn.Visible=false end
	
	for i=0,v.maxSpeed,v.spInc do
		local ln = gauges.ln:clone()
		ln.Parent = lnn
		ln.Rotation = 45 + 225*(i/v.maxSpeed)
		ln.Num.Text = i
		ln.Num.TextSize = 14
		ln.Num.Rotation = -ln.Rotation
		ln.Frame:Destroy()
		ln.Num.Visible=true
		ln.Visible=true
	end
end

if isOn.Value then
	gauges:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
end

isOn.Changed:connect(function()
	if isOn.Value then
		gauges:TweenPosition(UDim2.new(0, 0, 0, 0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)
	end
end)

values.RPM.Changed:connect(function()
	gauges.Tach.Needle.Rotation = 45 + 225 * math.min(1,values.RPM.Value / (revEnd*1000))
end)

local _TCount = 0

if _Tune.Aspiration ~= "Natural" and _Tune.Engine then
	if _Tune.Aspiration == "Single" or _Tune.Aspiration == "Super" then 
		_TCount = 1 
	elseif _Tune.Aspiration == "Double" then 
		_TCount = 2 
	end
	values.Boost.Changed:connect(function()
		local boost = math.floor(values.Boost.Value)
		if _Tune.Aspiration~="Super" then boost = (math.floor(values.Boost.Value)*1.2)-((_Tune.Boost*_TCount)/5) end
		gauges.Boost.Needle.Rotation = 45 + 270 * math.min(1,(values.Boost.Value/(_Tune.Boost)/_TCount))
		gauges.PSI.Text = tostring(math.floor(boost).." PSI")
	end)
else
	gauges.Boost:Destroy()
end

values.Gear.Changed:connect(function()
	local gearText = values.Gear.Value
	if gearText == 0 then gearText = "N"
	elseif gearText == -1 then gearText = "R"
	end
	gauges.Gear.Text = gearText
end)

values.TCS.Changed:connect(function()
	if _Tune.TCSEnabled then
		if values.TCS.Value then
			gauges.TCS.TextColor3 = Color3.new(1,170/255,0)
			gauges.TCS.TextStrokeColor3 = Color3.new(1,170/255,0)
			if values.TCSActive.Value then
				wait()
				gauges.TCS.Visible = not gauges.TCS.Visible
			else
				wait()
				gauges.TCS.Visible = false
			end
		else
			gauges.TCS.Visible = true
			gauges.TCS.TextColor3 = Color3.new(1,0,0)
			gauges.TCS.TextStrokeColor3 = Color3.new(1,0,0)
		end
	else
		gauges.TCS.Visible = false
	end
end)

values.TCSActive.Changed:connect(function()
	if _Tune.TCSEnabled then
		if values.TCSActive.Value and values.TCS.Value then
			wait()
			gauges.TCS.Visible = not gauges.TCS.Visible
		elseif not values.TCS.Value then
			wait()
			gauges.TCS.Visible = true
		else
			wait()
			gauges.TCS.Visible = false
		end
	else
		gauges.TCS.Visible = false
	end
end)

gauges.TCS.Changed:connect(function()
	if _Tune.TCSEnabled then
		if values.TCSActive.Value and values.TCS.Value then
			wait()
			gauges.TCS.Visible = not gauges.TCS.Visible
		elseif not values.TCS.Value then
			wait()
			gauges.TCS.Visible = true
		end
	else
		if gauges.TCS.Visible then
			gauges.TCS.Visible = false
		end
	end
end)

values.ABS.Changed:connect(function()
	if _Tune.ABSEnabled then
		if values.ABS.Value then
			gauges.ABS.TextColor3 = Color3.new(1,170/255,0)
			gauges.ABS.TextStrokeColor3 = Color3.new(1,170/255,0)
			if values.ABSActive.Value then
				wait()
				gauges.ABS.Visible = not gauges.ABS.Visible
			else
				wait()
				gauges.ABS.Visible = false
			end
		else
			gauges.ABS.Visible = true
			gauges.ABS.TextColor3 = Color3.new(1,0,0)
			gauges.ABS.TextStrokeColor3 = Color3.new(1,0,0)
		end
	else
		gauges.ABS.Visible = false
	end
end)

values.ABSActive.Changed:connect(function()
	if _Tune.ABSEnabled then
		if values.ABSActive.Value and values.ABS.Value then
			wait()
			gauges.ABS.Visible = not gauges.ABS.Visible
		elseif not values.ABS.Value then
			wait()
			gauges.ABS.Visible = true
		else
			wait()
			gauges.ABS.Visible = false
		end
	else
		gauges.ABS.Visible = false
	end
end)

gauges.ABS.Changed:connect(function()
	if _Tune.ABSEnabled then
		if values.ABSActive.Value and values.ABS.Value then
			wait()
			gauges.ABS.Visible = not gauges.ABS.Visible
		elseif not values.ABS.Value then
			wait()
			gauges.ABS.Visible = true
		end
	else
		if gauges.ABS.Visible then
			gauges.ABS.Visible = false
		end
	end
end)


function PBrake()
	gauges.PBrake.Visible = values.PBrake.Value
end
values.PBrake.Changed:connect(PBrake)

function Gear()
	if values.TransmissionMode.Value == "Auto" then
		gauges.TMode.Text = "A/T"
		gauges.TMode.BackgroundColor3 = Color3.new(1,170/255,0)
	elseif values.TransmissionMode.Value == "Semi" then
		gauges.TMode.Text = "S/T"
		gauges.TMode.BackgroundColor3 = Color3.new(0, 170/255, 127/255) 
	else
		gauges.TMode.Text = "M/T"
		gauges.TMode.BackgroundColor3 = Color3.new(1,85/255,.5)
	end
end
values.TransmissionMode.Changed:connect(Gear)

values.Velocity.Changed:connect(function(property)
	gauges.Speedo.Needle.Rotation = 45 + 225 * math.min(1,UNITS[currentUnits].scaling*values.Velocity.Value.Magnitude/UNITS[currentUnits].maxSpeed)
	gauges.Speed.Text = math.floor(UNITS[currentUnits].scaling*values.Velocity.Value.Magnitude) .. " "..UNITS[currentUnits].units
end)

gauges.Speed.MouseButton1Click:connect(function()
	if currentUnits==#UNITS then
		currentUnits = 1
	else
		currentUnits = currentUnits+1
	end
	for i,v in pairs(gauges.Speedo:GetChildren()) do
		v.Visible=v.Name==UNITS[currentUnits].units or v.Name=="Needle" or v.Name=="lns"
	end
	gauges.Speed.Text = math.floor(UNITS[currentUnits].scaling*values.Velocity.Value.Magnitude) .. " "..UNITS[currentUnits].units
end)

wait(.1)
Gear()
PBrake()
