-- Mode status:
-- 0/4 = Off
-- 1 = Auto
-- 2 = On


local motionSensor = script.Parent.Parent.Parent.SensorFunction.SensorScript
local Mode = script.Parent.Parent.Parent.Parent.Mode.Value
local LED = script.Parent.Parent.Parent.LED
local Off = script.Parent.Parent.Off
local On = script.Parent.Parent.On
local Auto = script.Parent.Parent.Sensor
local status = script.Parent.Parent.Parent.Parent.State

function onClicked()
	--Auto to Off
	if Mode == 1 then
		script.Parent.Sound_:Play()
		status.Value = 0
		motionSensor.Disabled = true
		Auto.Transparency = 1	
		On.Transparency = 1
		Off.Transparency = 0
		LED.BrickColor = BrickColor.new("Maroon")
		LED.Material = "Neon"
		Mode = 0
		wait(1)
		script.Parent.Sound:Play()
		--Off to On	
	elseif Mode == 0 then
		script.Parent.Sound_:Play()
		status.Value = 1
		motionSensor.Disabled = true
		Auto.Transparency = 1
		On.Transparency = 0
		Off.Transparency = 1		
		LED.BrickColor = BrickColor.new("Really red")
		LED.Material = "Neon"
		Mode = 2
		wait(1)
		script.Parent.Sound:Play()
		--On to Off		
	elseif Mode == 2 then
		script.Parent.Sound_:Play()
		status.Value = 0
		motionSensor.Disabled = true
		Auto.Transparency = 1	
		On.Transparency = 1
		Off.Transparency = 0
		LED.BrickColor = BrickColor.new("Maroon")
		LED.Material = "Neon"
		Mode = 4
		wait(1)
		script.Parent.Sound:Play()
		--Off to Auto		
	elseif Mode == 4 then
		script.Parent.Sound_:Play()
		status.Value = 0
		motionSensor.Disabled = false
		Auto.Transparency = 0
		On.Transparency = 1
		Off.Transparency = 1
		LED.BrickColor = BrickColor.new("Forest green")	
		LED.Material = "Neon"	
		Mode = 1
		wait(1)
		script.Parent.Sound:Play()
	end
end

script.Parent.ClickDetector.MouseClick:Connect(onClicked)
