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")local K=script.Parent.Parent.Car.Value K.DriveSeat.HeadsUpDisplay=false local L=require(K["\065-\067\104\097\115\115\105\115 \084\117\110\101"])local M=L.PeakRPM local J=L.Redline local V=8 local U=K.Body.Dash.D.G.Tac.Needle local c=K.Body.Dash.D.G.Spd.Needle local d={}if L.Config=="\070\087\068"or L.Config=="\065\087\068"then if K.Wheels:FindFirstChild("\070\076")~=nil then table.insert(d,K.Wheels.FL)end if K.Wheels:FindFirstChild("\070\082")~=nil then table.insert(d,K.Wheels.FR)end if K.Wheels:FindFirstChild("\070")~=nil then table.insert(d,K.Wheels.F)end end if L.Config=="\082\087\068"or L.Config=="\065\087\068"then if K.Wheels:FindFirstChild("\082\076")~=nil then table.insert(d,K.Wheels.RL)end if K.Wheels:FindFirstChild("\082\082")~=nil then table.insert(d,K.Wheels.RR)end if K.Wheels:FindFirstChild("\082")~=nil then table.insert(d,K.Wheels.R)end end local m=0 for K,L in pairs(d)do if L.Size.x>m then m=L.Size.x end end d=nil local x=math.ceil(((((m*math.pi)*J)/60)/L.Ratios[#L.Ratios])/L.FinalDrive)local P=160 local r=math.max(math.ceil(P/200)*20,20)for K=0,V*2,1 do local L=script.Parent.ln:clone()L.Parent=script.Parent.Tach L.Rotation=45+(K*225)/(V*2)L.Num.Text=K/2 L.Num.Rotation=-L.Rotation if K*500>=math.floor(J/500)*500 then L.Frame.BackgroundColor3=Color3.new(1,0,0)if K<V*2 then ln2=L:clone()ln2.Parent=script.Parent.Tach ln2.Rotation=45+((K+.5)*225)/(V*2)ln2.Num:Destroy()ln2.Visible=true end end if K%2==0 then L.Frame.Size=UDim2.new(0,3,0,10)L.Frame.Position=UDim2.new(0,-1,0,100)L.Num.Visible=true else L.Num:Destroy()end L.Visible=true end for K=1,90,1 do local L=script.Parent.ln:clone()L.Parent=script.Parent.Speedo L.Rotation=45+225*(K/90)if K%2==0 then L.Frame.Size=UDim2.new(0,2,0,10)L.Frame.Position=UDim2.new(0,-1,0,100)else L.Frame.Size=UDim2.new(0,3,0,5)end L.Num:Destroy()L.Visible=true end for K=0,P,r do local L=script.Parent.ln:clone()L.Parent=script.Parent.Speedo L.Rotation=45+225*(K/P)L.Num.Text=math.floor(K)L.Num.Rotation=-L.Rotation L.Frame:Destroy()L.Num.Visible=true L.Visible=true end if K.DriveSeat.IsOn.Value then script.Parent:TweenPosition(UDim2.new(0,0,0,0),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,1,true)end K.DriveSeat.IsOn.Changed:connect(function()if K.DriveSeat.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/(V*1000))U.Rotation=-90+(script.Parent.Parent.Values.RPM.Value*270)/8000 end)script.Parent.Parent.Values.Gear.Changed:connect(function()local L=script.Parent.Parent.Values.Gear.Value if L==0 then L="\078"K.Body.Dash.D.G.Info.Gear.Text="\078"elseif L==-1 then L="\082"K.Body.Dash.D.G.Info.Gear.Text="\082"end script.Parent.Gear.Text=L K.Body.Dash.D.G.Info.Gear.Text=L 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(K)script.Parent.Speedo.Needle.Rotation=45+225*math.min(1,script.Parent.Parent.Values.Velocity.Value.Magnitude/(P*1.6))c.Rotation=-90+(script.Parent.Parent.Values.Velocity.Value.Magnitude*270)/256 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")

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 = 8
local intach = car.Body.Dash.D.G.Tac.Needle
local inspd = car.Body.Dash.D.G.Spd.Needle

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 maxSp = 160
local spInc = math.max(math.ceil(maxSp / 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(_lRPM / 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, maxSp, spInc do
	local ln = script.Parent.ln:clone()
	ln.Parent = script.Parent.Speedo
	ln.Rotation = 45 + 225 * (i / maxSp)
	ln.Num.Text = math.floor(i)
	ln.Num.Rotation = -ln.Rotation
	ln.Frame:Destroy()
	ln.Num.Visible = true
	ln.Visible = true
end

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

car.DriveSeat.IsOn.Changed:connect(function()
	if car.DriveSeat.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))
	intach.Rotation = -90 + script.Parent.Parent.Values.RPM.Value * 270 / 8000
end)

script.Parent.Parent.Values.Gear.Changed:connect(function()
	local gearText = script.Parent.Parent.Values.Gear.Value
	if gearText == 0 then
		gearText = "N"
		car.Body.Dash.D.G.Info.Gear.Text = "N"
	elseif gearText == -1 then
		gearText = "R"
		car.Body.Dash.D.G.Info.Gear.Text = "R"
	end
	script.Parent.Gear.Text = gearText
	car.Body.Dash.D.G.Info.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 / (maxSp * 1.6))
	inspd.Rotation = -90 + script.Parent.Parent.Values.Velocity.Value.Magnitude * 270 / 256
	script.Parent.Speed.Text = math.floor(script.Parent.Parent.Values.Velocity.Value.Magnitude / 1.6) .. " MPH"
end)
