-- 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.Light.Material=Enum.Material.Neon
		car.Body.Lights.Light.Light.Enabled = true
function off()
		car.Body.Lights.Light.Light.Enabled = false
		car.Body.Lights.Light.Material=Enum.Material.SmoothPlastic
		for i,v in pairs(car.Body.Lights:GetChildren()) do
		end
end
end
function auto()
	if (game.Lighting:GetMinutesAfterMidnight()<390 or game.Lighting:GetMinutesAfterMidnight()>1050) then
		car.Body.Lights.Light.Material=Enum.Material.Neon
		car.Body.Lights.Light.Light.Enabled = true
	else
		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"
	elseif script.parent.Text == "Lights: On" then
		script.Parent.Text = "Lights: Off"
		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.Material=Enum.Material.Neon
				else
					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()
