script.Parent:WaitForChild("\083\112\101\101\100\111")script.Parent:WaitForChild("\084\097\099\104")script.Parent:WaitForChild("\108\110")script.Parent:WaitForChild("\071\101\097\114")script.Parent:WaitForChild("\083\112\101\101\100")BrakeON="\082\101\097\108\108\121 \114\101\100"BrakeOFF="\087\104\105\116\101"ReverseON="\073\110\115\116\105\116\117\116\105\111\110\097\108 \119\104\105\116\101"ReverseOFF="\087\104\105\116\101"local x=script.Parent.Parent.Car.Value x.DriveSeat.HeadsUpDisplay=false local t=require(x["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local Z=t.PeakRPM local o=t.Redline local b=math.ceil(o/1000)local V={}if t.Config=="\070\087\068"or t.Config=="\065\087\068"then if x.Wheels:FindFirstChild("\070\076")~=nil then table.insert(V,x.Wheels.FL)end if x.Wheels:FindFirstChild("\070\082")~=nil then table.insert(V,x.Wheels.FR)end if x.Wheels:FindFirstChild("\070")~=nil then table.insert(V,x.Wheels.F)end end if t.Config=="\082\087\068"or t.Config=="\065\087\068"then if x.Wheels:FindFirstChild("\082\076")~=nil then table.insert(V,x.Wheels.RL)end if x.Wheels:FindFirstChild("\082\082")~=nil then table.insert(V,x.Wheels.RR)end if x.Wheels:FindFirstChild("\082")~=nil then table.insert(V,x.Wheels.R)end end local y=0 for x,t in pairs(V)do if t.Size.x>y then y=t.Size.x end end V=nil local j=math.ceil(((((y*math.pi)*o)/60)/t.Ratios[#t.Ratios])/t.FinalDrive)local v=math.max(math.ceil(j/200)*20,20)for x=0,b*2,1 do local t=script.Parent.ln:clone()t.Parent=script.Parent.Tach t.Rotation=45+(x*225)/(b*2)t.Num.Text=x/2 t.Num.Rotation=-t.Rotation if x*500>=math.floor(Z/500)*500 then t.Frame.BackgroundColor3=Color3.new(1,0,0)if x<b*2 then ln2=t:clone()ln2.Parent=script.Parent.Tach ln2.Rotation=45+((x+.5)*225)/(b*2)ln2.Num:Destroy()ln2.Visible=true end end if x%2==0 then t.Frame.Size=UDim2.new(0,3,0,10)t.Frame.Position=UDim2.new(0,-1,0,100)t.Num.Visible=true else t.Num:Destroy()end t.Visible=true end for x=1,90,1 do local t=script.Parent.ln:clone()t.Parent=script.Parent.Speedo t.Rotation=45+225*(x/90)if x%2==0 then t.Frame.Size=UDim2.new(0,2,0,10)t.Frame.Position=UDim2.new(0,-1,0,100)else t.Frame.Size=UDim2.new(0,3,0,5)end t.Num:Destroy()t.Visible=true end for x=0,j,v do local t=script.Parent.ln:clone()t.Parent=script.Parent.Speedo t.Rotation=45+225*(x/j)t.Num.Text=x t.Num.Rotation=-t.Rotation t.Frame:Destroy()t.Num.Visible=true t.Visible=true end if script.Parent.Parent.IsOn.Value then script.Parent:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)end script.Parent.Parent.IsOn.Changed:connect(function()if script.Parent.Parent.IsOn.Value then script.Parent:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)end end)script.Parent.Parent.Values.RPM.Changed:connect(function()script.Parent.Tach.Needle.Rotation=45+225*math.min(1,script.Parent.Parent.Values.RPM.Value/(b*1000))end)script.Parent.Parent.Values.Gear.Changed:connect(function()local t=script.Parent.Parent.Values.Gear.Value if t==0 then t="\078"if t=="\078"then for x,t in pairs(x.Body.ReverseLights:GetChildren())do t.Material=Enum.Material.SmoothPlastic t.BrickColor=BrickColor.new(ReverseOFF)t.PointLight.Enabled=false end end elseif t==-1 then t="\082"end if t=="\082"then for x,t in pairs(x.Body.ReverseLights:GetChildren())do t.Material=Enum.Material.Neon t.BrickColor=BrickColor.new(ReverseON)t.PointLight.Enabled=true end end script.Parent.Gear.Text=t end)script.Parent.Parent.Values.TCS.Changed:connect(function()if script.Parent.Parent.Values.TCS.Value then script.Parent.TCS.TextColor3=Color3.new(1,.66666666666667,0)script.Parent.TCS.TextStrokeColor3=Color3.new(1,.66666666666667,0)if script.Parent.Parent.Values.TCSActive.Value then wait()script.Parent.TCS.Visible=not script.Parent.TCS.Visible else wait()script.Parent.TCS.Visible=false end else script.Parent.TCS.Visible=true script.Parent.TCS.TextColor3=Color3.new(1,0,0)script.Parent.TCS.TextStrokeColor3=Color3.new(1,0,0)end end)script.Parent.Parent.Values.TCSActive.Changed:connect(function()if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=not script.Parent.TCS.Visible elseif not script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=true else wait()script.Parent.TCS.Visible=false end end)script.Parent.TCS.Changed:connect(function()if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=not script.Parent.TCS.Visible elseif not script.Parent.Parent.Values.TCS.Value then wait()script.Parent.TCS.Visible=true end end)script.Parent.Parent.Values.PBrake.Changed:connect(function()script.Parent.PBrake.Visible=script.Parent.Parent.Values.PBrake.Value end)script.Parent.Parent.Values.TransmissionMode.Changed:connect(function()if script.Parent.Parent.Values.TransmissionMode.Value=="\065\117\116\111"then script.Parent.TMode.Text="\065\047\084"script.Parent.TMode.BackgroundColor3=Color3.new(1,.66666666666667,0)elseif script.Parent.Parent.Values.TransmissionMode.Value=="\083\101\109\105"then script.Parent.TMode.Text="\083\047\084"script.Parent.TMode.BackgroundColor3=Color3.new(0,.66666666666667,.49803921568627)else script.Parent.TMode.Text="\077\047\084"script.Parent.TMode.BackgroundColor3=Color3.new(1,.33333333333333,.5)end end)script.Parent.Parent.Values.Velocity.Changed:connect(function(x)script.Parent.Speedo.Needle.Rotation=45+225*math.min(1,script.Parent.Parent.Values.Velocity.Value.Magnitude/j)script.Parent.Speed.Text=math.floor(script.Parent.Parent.Values.Velocity.Value.Magnitude/1.6).." \077\080\072"end)
--[[
		___      _______                _     
	   / _ |____/ ___/ /  ___ ____ ___ (_)__ 
	  / __ /___/ /__/ _ \/ _ `(_-<(_-</ (_-<
	 /_/ |_|   \___/_//_/\_,_/___/___/_/___/
 						SecondLogic @ Inspare
]]

script.Parent:WaitForChild("Speedo")
script.Parent:WaitForChild("Tach")
script.Parent:WaitForChild("ln")
script.Parent:WaitForChild("Gear")
script.Parent:WaitForChild("Speed")
BrakeON = "Really red"
BrakeOFF = "White"
ReverseON = "Institutional white"
ReverseOFF = "White"

local car = script.Parent.Parent.Car.Value
car.DriveSeat.HeadsUpDisplay = false

local _Tune = require(car["A-Chassis Tune"])

local _pRPM = _Tune.PeakRPM
local _lRPM = _Tune.Redline

local revEnd = math.ceil(_lRPM / 1000)

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
local maxSpeed = math.ceil(wDia * math.pi * _lRPM / 60 / _Tune.Ratios[#_Tune.Ratios] / _Tune.FinalDrive)
local spInc = math.max(math.ceil(maxSpeed / 200) * 20, 20)

for i = 0, revEnd * 2 do
	local ln = script.Parent.ln:clone()
	ln.Parent = script.Parent.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 = script.Parent.Tach
			ln2.Rotation = 45 + (i + 0.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

for i = 1, 90 do
	local ln = script.Parent.ln:clone()
	ln.Parent = script.Parent.Speedo
	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
for i = 0, maxSpeed, spInc do
	local ln = script.Parent.ln:clone()
	ln.Parent = script.Parent.Speedo
	ln.Rotation = 45 + 225 * (i / maxSpeed)
	ln.Num.Text = i
	ln.Num.Rotation = -ln.Rotation
	ln.Frame:Destroy()
	ln.Num.Visible = true
	ln.Visible = true
end

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

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

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

script.Parent.Parent.Values.Gear.Changed:connect(function()
	local gearText = script.Parent.Parent.Values.Gear.Value
	if gearText == 0 then
		gearText = "N"
		if gearText == "N" then
			for index, child in pairs(car.Body.ReverseLights:GetChildren()) do
				child.Material = Enum.Material.SmoothPlastic
				child.BrickColor = BrickColor.new(ReverseOFF)
				child.PointLight.Enabled = false
			end
		end
	elseif gearText == -1 then
		gearText = "R"
	end
	if gearText == "R" then
		for index, child in pairs(car.Body.ReverseLights:GetChildren()) do
			child.Material = Enum.Material.Neon
			child.BrickColor = BrickColor.new(ReverseON)
			child.PointLight.Enabled = true
		end
	end
	script.Parent.Gear.Text = gearText
end)

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

script.Parent.Parent.Values.TCSActive.Changed:connect(function()
	if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = not script.Parent.TCS.Visible
	elseif not script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = true
	else
		wait()
		script.Parent.TCS.Visible = false
	end
end)

script.Parent.TCS.Changed:connect(function()
	if script.Parent.Parent.Values.TCSActive.Value and script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = not script.Parent.TCS.Visible
	elseif not script.Parent.Parent.Values.TCS.Value then
		wait()
		script.Parent.TCS.Visible = true
	end
end)

script.Parent.Parent.Values.PBrake.Changed:connect(function()
	script.Parent.PBrake.Visible = script.Parent.Parent.Values.PBrake.Value
end)

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

script.Parent.Parent.Values.Velocity.Changed:connect(function(property)
	script.Parent.Speedo.Needle.Rotation = 45
		+ 225 * math.min(1, script.Parent.Parent.Values.Velocity.Value.Magnitude / maxSpeed)
	script.Parent.Speed.Text = math.floor(script.Parent.Parent.Values.Velocity.Value.Magnitude / 1.6) .. " MPH"
end)
