-- Remade by Truenus
wait(0.05)
local car = script.Parent.Parent.Car.Value
local GBrake = script.Parent.Parent.Values.Brake
function on()
		car.Body.Lights.RN.BrickColor=BrickColor.New("Maroon")
		car.Body.Lights.RN.Material=Enum.Material.Neon
		car.Body.Lights.Light.Material=Enum.Material.Neon
		car.Body.Lights.Light.Light.Enabled = true
		car.Body.Lights.Light.BrickColor=BrickColor.New("Institutional white")
		car.Body.Lights.RN.Light.Enabled = true
function off()
	car.Body.Lights.Light.BrickColor=BrickColor.New("Dark stone grey")
		car.Body.Lights.RN.Material=Enum.Material.SmoothPlastic
		car.Body.Lights.RN.BrickColor=BrickColor.New("Crimson")
		car.Body.Lights.Light.Light.Enabled = false
		car.Body.Lights.Light.Material=Enum.Material.SmoothPlastic
		car.Body.Lights.RN.Light.Enabled = false
		for i,v in pairs(car.Body.Lights:GetChildren()) do
			if v.Name == "Light2" then
				v.Material=Enum.Material.SmoothPlastic
				v.Light.Enabled = false
			end
		end
end
end
function on2()
	for i,v in pairs(car.Body.Lights:GetChildren()) do
		if v.Name == "Light2" then
			v.Material=Enum.Material.Neon
			v.Light.Enabled = true
			for i,v in pairs(car.Body.Lights:GetChildren()) do
				if v.Name == "Light" then
					v.BrickColor=BrickColor.new("Dark stone grey")
					v.Material = Enum.Material.SmoothPlastic
					v.Light.Enabled = false
				end
			end
		end
	end
end
function auto()
	if (game.Lighting:GetMinutesAfterMidnight()<0 or game.Lighting:GetMinutesAfterMidnight()>0) then
		car.Body.Lights.Light.Material=Enum.Material.Neon
		car.Body.Lights.Light.Light.Enabled = true
		car.Body.Lights.RN.BrickColor=BrickColor.New("Bright red")
		car.Body.Lights.RN.Light.Enabled = true
	else
		car.Body.Lights.RN.Light.Enabled = false
		car.Body.Lights.RN.Material=Enum.Material.SmoothPlastic
		car.Body.Lights.RN.BrickColor=BrickColor.New("Maroon")
		car.Body.Lights.Light.Light.Enabled = false
		car.Body.Lights.Light.Material=Enum.Material.SmoothPlastic
	end
end

script.Parent.MouseButton1Click:connect(function()
	if script.Parent.Text == "Lights: Auto" then
		on()
		script.Parent.Text = "Lights: On (1)"
	elseif script.parent.Text == "Lights: On (1)" then
		on2()
		script.Parent.Text = "Lights: On (2)"
	elseif script.Parent.Text == "Lights: On (2)" then
		off()
		script.Parent.Text = "Lights: Off"
	elseif script.parent.Text == "Lights: Off" then
		auto()
		script.Parent.Text = "Lights: Auto"
	end
end)

script.Parent.Parent.Values.Brake.Changed:connect(function()
	for i,v in pairs(car.Body.Lights:GetChildren()) do
		if v.Name=="R" then
			if v.Light.Enabled then
				if GBrake.Value>0 then
					v.Transparency=0
					v.Light.Brightness=12
					v.Light.Range=15
				else
					v.Transparency=.3
					v.Light.Brightness=8
					v.Light.Range=10
				end
			else
				v.Transparency=0
				if GBrake.Value>0 then
					v.BrickColor=BrickColor.new("Really red")
					v.Material=Enum.Material.Neon
				else
					v.BrickColor=BrickColor.new("Black")
					v.Material=Enum.Material.SmoothPlastic
				end
			end
		elseif v.Name=="RR" then
			if GBrake.Value>0 then
				v.Material=Enum.Material.Neon
				if v.Light.Enabled then
					v.Transparency = 1
				else
					v.Transparency = 0
				end
			else
				v.Transparency = 1
				if v.Light.Enabled then
					v.Material=Enum.Material.Neon
				else
					v.Material=Enum.Material.SmoothPlastic
				end
			end
		end
	end
end)

game.Lighting.Changed:connect(auto)
auto()