--Automatic Gauge Scaling

script.Parent.Parent.Values.RPM.Changed:connect(function()
	script.Parent["02"].BackgroundColor3 = Color3.new(math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/2000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/2000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/2000)))
	script.Parent["03"].BackgroundColor3 = Color3.new(math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/3000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/3000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/3000)))
	script.Parent["04"].BackgroundColor3 = Color3.new(math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/4000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/4000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/4000)))
	script.Parent["05"].BackgroundColor3 = Color3.new(math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/5000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/5000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/5000)))
	script.Parent["06"].BackgroundColor3 = Color3.new(math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/6000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/6000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/6000)))
	script.Parent["07"].BackgroundColor3 = Color3.new(math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/7000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/7000)),math.max(0.15,math.floor(script.Parent.Parent.Values.RPM.Value/7000)))
	script.Parent["08"].BackgroundColor3 = Color3.new(math.max(0.2,math.floor(script.Parent.Parent.Values.RPM.Value/8000)),0,0)
	script.Parent["09"].BackgroundColor3 = Color3.new(math.max(0.2,math.floor(script.Parent.Parent.Values.RPM.Value/9000)),0,0)
	script.Parent["10"].BackgroundColor3 = Color3.new(math.max(0.2,math.floor(script.Parent.Parent.Values.RPM.Value/10000)),0,0)
	script.Parent.Base.Rev.Rotation = -167+(math.max((1/9),((script.Parent.Parent.Values.RPM.Value/9000)-(1/9))))*138
	script.Parent.Base.Rev.ImageColor3 = Color3.new(1,(1-((script.Parent.Parent.Values.RPM.Value/9000)*8-7)),(1-((script.Parent.Parent.Values.RPM.Value/9000)*8-7)))
end)

script.Parent.Parent.Values.Gear.Changed:connect(function()
	local gearText = script.Parent.Parent.Values.Gear.Value
	local gearTextA = ""
	local gearTextB = ""
	if gearText == -1 then 
		gearText = "R"
		gearTextB = "N1234567"
	elseif gearText == 0 then 
		gearText = "N"
		gearTextA = "R"
		gearTextB = "1234567"
	elseif gearText == 1 then 
		gearTextA = "RN"
		gearTextB = "234567"
	elseif gearText == 2 then 
		gearTextA = "RN1"
		gearTextB = "34567"
	elseif gearText == 3 then 
		gearTextA = "RN12"
		gearTextB = "4567"
	elseif gearText == 4 then 
		gearTextA = "RN123"
		gearTextB = "567"
	elseif gearText == 5 then 
		gearTextA = "RN1234"
		gearTextB = "67"
	elseif gearText == 6 then 
		gearTextA = "RN12345"
		gearTextB = "7"
	elseif gearText == 7 then 
		gearTextA = "RN123456"
	end
	script.Parent.Gear.Text = gearText
	script.Parent.GearA.Text = gearTextA
	script.Parent.GearB.Text = gearTextB
end)

script.Parent.Parent.Values.TCS.Changed:connect(function()
	if _Tune.TCSEnabled then
		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
	else
		script.Parent.TCS.Visible = false
	end
end)

script.Parent.Parent.Values.TCSActive.Changed:connect(function()
	if _Tune.TCSEnabled then
		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
	else
		script.Parent.TCS.Visible = false
	end
end)

script.Parent.TCS.Changed:connect(function()
	if _Tune.TCSEnabled then
		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
	else
		if script.Parent.TCS.Visible then
			script.Parent.TCS.Visible = false
		end
	end
end)
script.Parent.Parent.Values.Gear.Changed:connect(function()
	if script.Parent.Parent.Values.LaunchMode.Value == true then
		script.Parent.Parent.Values.LaunchMode.Value = false
	end
	local gearText = script.Parent.Parent.Values.Gear.Value
	if gearText == 0 then gearText = "N"
	elseif gearText == -1 then gearText = "R"
	end
	script.Parent.Gear.Text = gearText
end)

script.Parent.Parent.Values.LaunchMode.Changed:connect(function()
	if script.Parent.Parent.Values.LaunchMode.Value == true then
		script.Parent.Launch.Visible = true
	else
		script.Parent.Launch.Visible = false
	end
end)