--Active


Values.Gear.Changed:Connect(function(Value)
	local TextLabel = Dash.Gear.TextValue
	if Value == -1 then TextLabel.Text = "R"
	elseif Value == 0 then TextLabel.Text = "N"
	else TextLabel.Text = Value end
end)

Values.RPM.Changed:Connect(function(Value)
	for i = 1, 30 do
		if Value >= (_Tune.Redline - 500) / 30 * i then
			Dash.Tach.ln[i].BackgroundTransparency = 0
		else
			Dash.Tach.ln[i].BackgroundTransparency = 0.7
		end
	end
	for i = 1, 3 do
		if Value > _Tune.Redline - i * 750 then
			Dash.Parent.Parent.Parent["RPM"..i].Material = "Neon"
		else
			Dash.Parent.Parent.Parent["RPM"..i].Material = "SmoothPlastic"
		end
	end
end)

Values.Velocity.Changed:Connect(function(Value)
	Dash.Speed.TextValue.Text = math.floor(Value.Magnitude * Speed_Units)
end)

Values.PBrake.Changed:Connect(function() CheckValue(Values.PBrake) end)
Values.ABS.Changed:Connect(function() CheckValue(Values.ABS) end)
Values.TCS.Changed:Connect(function() CheckValue(Values.TCS) end)

Values.ABSActive.Changed:Connect(function(Value)
	wait()
	if Values.ABS.Value == true then
		if Dash.ABS.ImageTransparency == 0 then
			Dash.ABS.ImageTransparency = 0.7
		else
			Dash.ABS.ImageTransparency = 0
		end
	end
end)

Values.TCSActive.Changed:Connect(function(Value)
	wait()
	if Values.TCS.Value == true then
		if Dash.TCS.ImageTransparency == 0 then
			Dash.TCS.ImageTransparency = 0.7
		else
			Dash.TCS.ImageTransparency = 0
		end
	end
end)

Values.Horsepower.Changed:Connect(function(Value)
	if Value > tonumber(Dash.HP.TextValue.Text) then
		Dash.HP.TextValue.Text = math.floor(Value)
	end
end)

Values.Torque.Changed:Connect(function(Value)
	if Value > tonumber(Dash.TQ.TextValue.Text) then
		Dash.TQ.TextValue.Text = math.floor(Value)
	end
end)

game.Players.LocalPlayer.Character.Humanoid.Touched:Connect(function(part)
	if part.Name == "Start" and part.Parent.Name == "Wes_Timing_System_3" then
		local timeStart = tick()
		wait()
		if Dash.Time.TextValue.Text ~= "--:---.---" then
			game["Run Service"]:UnbindFromRenderStep("GaugeTimer")
			wait(3)
		end
		local function updateTimer()
			local value = tick() - timeStart
			value = math.floor(value*1000)/1000
			local min = math.floor(value/60)
			local sec = math.floor(value)-60*min
			local milisec = math.floor((value-sec-min*60)*1000+0.5)

			if min > 0 and min < 10 then min = "0"..tostring(min)
			elseif min < 1 then min = "00" end

			if sec > 0 and sec < 10 then sec = "0"..tostring(sec)
			elseif sec < 1 then sec = "00" end

			if string.len(tostring(milisec)) == 2 then milisec = tostring(milisec).."0"
			elseif string.len(tostring(milisec)) == 1 then milisec = tostring(milisec).."00" end

			Dash.Time.TextValue.Text = min..":"..sec.."."..milisec
		end

		game["Run Service"]:BindToRenderStep("GaugeTimer",50,updateTimer)
	end
end)
