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


mouse.KeyDown:connect(function(key)
	if key=="v" then
		script.Parent.Visible=not script.Parent.Visible
	end
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.Tac.Gear.Text = "N"
		car.DriveSeat.Filter:FireServer('reverse',false)
	elseif gearText == -1 then
		gearText = "R"
		car.Body.Dash.D.G.Tac.Gear.Text = "R"
		car.DriveSeat.Filter:FireServer('reverse',true)
	end
	car.Body.Dash.D.G.Tac.Gear.Text = gearText
	car.Body.Dash.D.G.TacB.Gear.Text = gearText
	script.Parent.Tac.G.Gear.Text = gearText
end)

while wait() do
	local speed = math.floor(UNITS[currentUnits].scaling*script.Parent.Parent.Values.Velocity.Value.Magnitude)
	local kph = math.floor(UNITS[2].scaling*script.Parent.Parent.Values.Velocity.Value.Magnitude)
	for i, v in pairs(script.Parent.Tac.G:GetChildren()) do
		if v:IsA("Frame") and v.Name ~= "Unit" then
			local rt = math.abs(script.Parent.Tac.G.Needle.AbsoluteRotation - (v.AbsoluteRotation))
			v.Num.TextSize = math.max(18,(18 - (((rt/4)^2)-18)))
		end
	end
	for i, u in pairs(script.Parent.Spd.G:GetChildren()) do
		for j,v in pairs(u:GetChildren()) do
			if v:IsA("Frame") and v.Name ~= "Unit" then
				local st = math.abs(script.Parent.Spd.G.Needle.AbsoluteRotation - (v.AbsoluteRotation))
				if v:FindFirstChild("Num") then
					v.Num.TextSize = math.max(16,(16 - (((st/4)^2)-16)))
				end
			end
		end
	end
	car.Body.Dash.S.G.HB.S.HP.Text = (math.floor(script.Parent.Parent.Values.Horsepower.Value*0.75))
	car.Body.Dash.S.G.HB.S.Spd.Text = kph
end
