if autoscaling then local P={}if _Tune.Config=="\070\087\068"or _Tune.Config=="\065\087\068"then if car.Wheels:FindFirstChild("\070\076")~=nil then table.insert(P,car.Wheels.FL)end if car.Wheels:FindFirstChild("\070\082")~=nil then table.insert(P,car.Wheels.FR)end if car.Wheels:FindFirstChild("\070")~=nil then table.insert(P,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(P,car.Wheels.RL)end if car.Wheels:FindFirstChild("\082\082")~=nil then table.insert(P,car.Wheels.RR)end if car.Wheels:FindFirstChild("\082")~=nil then table.insert(P,car.Wheels.R)end end local T=0 for P,N in pairs(P)do if N.Size.x>T then T=N.Size.x end end P=nil for P,N in pairs(UNITS)do N.maxSpeed=math.ceil((((((N.scaling*T)*math.pi)*_lRPM)/60)/_Tune.Ratios[#_Tune.Ratios])/_Tune.FinalDrive)N.spInc=math.max(math.ceil(N.maxSpeed/200)*20,20)end end local P=Instance.new("\070\114\097\109\101",script.Parent.Speedo)P.Name="\108\110\115"P.BackgroundTransparency=1 P.BorderSizePixel=0 P.Size=UDim2.new(0,0,0,0)for T=1,90,1 do local N=script.Parent.ln:clone()N.Parent=P N.Rotation=45+225*(T/90)if T%2==0 then N.Frame.Size=UDim2.new(0,2,0,10)N.Frame.Position=UDim2.new(0,-1,0,100)else N.Frame.Size=UDim2.new(0,3,0,5)end N.Num:Destroy()N.Visible=false end for P,T in pairs(UNITS)do local N=Instance.new("\070\114\097\109\101",script.Parent.Speedo)N.BackgroundTransparency=1 N.BorderSizePixel=0 N.Size=UDim2.new(0,0,0,0)N.Name=T.units if P~=1 then N.Visible=false end for P=0,T.maxSpeed,T.spInc do local p=script.Parent.ln:clone()p.Parent=N p.Rotation=45+225*(P/T.maxSpeed)p.Num.Text=P p.Num.TextSize=14 p.Num.Rotation=-p.Rotation p.Frame:Destroy()p.Num.Visible=true p.Visible=false end end script.Parent.Parent.Values.Gear.Changed:connect(function()local P=script.Parent.Parent.Values.Gear.Value if P==0 then P="\078"end if P==-1 then P="\082"end script.Parent.Gear.Text="\071\101\097\114 \058 "..(P.." \047 \054")end)local T=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")L=false T.InputBegan:connect(function(P,T)if not T then if P.KeyCode==Enum.KeyCode.Z then if L==false then script.Parent.Left.ImageColor3=Color3.fromRGB(142,255,169)L=true else script.Parent.Left.ImageColor3=Color3.fromRGB(255,255,255)L=false end end end end)
--Automatic Gauge Scaling
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)
		v.spInc = math.max(math.ceil(v.maxSpeed / 200) * 20, 20)
	end
end

local lns = Instance.new("Frame", script.Parent.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 = script.Parent.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 = false
end

for i, v in pairs(UNITS) do
	local lnn = Instance.new("Frame", script.Parent.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 = script.Parent.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 = false
	end
end

script.Parent.Parent.Values.Gear.Changed:connect(function()
	local gearText = script.Parent.Parent.Values.Gear.Value
	if gearText == 0 then
		gearText = "N"
	end
	if gearText == -1 then
		gearText = "R"
	end
	script.Parent.Gear.Text = "Gear : " .. gearText .. " / 6"
end)

local UIS = game:GetService("UserInputService")
L = false
UIS.InputBegan:connect(function(i, GP)
	if not GP then
		if i.KeyCode == Enum.KeyCode.Z then
			if L == false then
				script.Parent.Left.ImageColor3 = Color3.fromRGB(142, 255, 169)
				L = true
			else
				script.Parent.Left.ImageColor3 = Color3.fromRGB(255, 255, 255)
				L = false
			end
		end
	end
end)
