script.Parent.OnServerEvent:connect(function(d,u)if lt~=1 then pr=true else pr=false end lt=u if lt==0 then RefMt.DesiredAngle=RefMt.CurrentAngle%math.rad(360)RefMt.CurrentAngle=RefMt.CurrentAngle%math.rad(360)UpdateLt(1,white)UpdatePt(false,white)StopMt(pr)repeat wait()until lt~=0 elseif lt==1 then wait(.25)RefMt.DesiredAngle=RefMt.CurrentAngle%math.rad(360)RefMt.CurrentAngle=RefMt.CurrentAngle%math.rad(360)UpdateLt(.25,blue)UpdatePt(true,blue)UpdateMt(0,math.rad(225),4)wait(.75)repeat UpdateMt(0,math.rad(135),0)wait(.5)if lt~=1 then break end UpdateMt(0,math.rad(225),0)wait(.5)until lt~=1 elseif lt==2 then UpdateLt(.25,amber)UpdatePt(true,amber)UpdateMt(0,9000000000.0,1)repeat if math.deg(RefMt.CurrentAngle%math.rad(360))>=90 then UpdateLt(.25,red)end if math.deg(RefMt.CurrentAngle%math.rad(360))>=90 then UpdatePt(true,red)end if math.deg(RefMt.CurrentAngle%math.rad(360))>=270 then UpdateLt(.25,amber)end if math.deg(RefMt.CurrentAngle%math.rad(360))>=270 then UpdatePt(true,amber)end wait()until lt~=2 elseif lt==3 then wait(.16666666666667)UpdateLt(.25,blue)UpdatePt(true,blue)UpdateMt(0,9000000000.0,1)repeat wait()until lt~=3 end end)
--LIGHTING FUNCTIONS

script.Parent.OnServerEvent:connect(function(pl, n)
	if lt ~= 1 then
		pr = true
	else
		pr = false
	end
	lt = n
	if lt == 0 then
		RefMt.DesiredAngle = RefMt.CurrentAngle % math.rad(360)
		RefMt.CurrentAngle = RefMt.CurrentAngle % math.rad(360)
		UpdateLt(1, white)
		UpdatePt(false, white)
		StopMt(pr)
		repeat
			wait()
		until lt ~= 0
	elseif lt == 1 then
		wait(0.25)
		RefMt.DesiredAngle = RefMt.CurrentAngle % math.rad(360)
		RefMt.CurrentAngle = RefMt.CurrentAngle % math.rad(360)
		UpdateLt(0.25, blue)
		UpdatePt(true, blue)
		UpdateMt(0, math.rad(225), 4)
		wait(0.75)
		repeat
			UpdateMt(0, math.rad(135), 0)
			wait(0.5)
			if lt ~= 1 then
				break
			end
			UpdateMt(0, math.rad(225), 0)
			wait(0.5)
		until lt ~= 1
	elseif lt == 2 then
		UpdateLt(0.25, amber)
		UpdatePt(true, amber)
		UpdateMt(0, 9e9, 1)
		repeat
			if math.deg(RefMt.CurrentAngle % math.rad(360)) >= 90 then
				UpdateLt(0.25, red)
			end
			if math.deg(RefMt.CurrentAngle % math.rad(360)) >= 90 then
				UpdatePt(true, red)
			end
			if math.deg(RefMt.CurrentAngle % math.rad(360)) >= 270 then
				UpdateLt(0.25, amber)
			end
			if math.deg(RefMt.CurrentAngle % math.rad(360)) >= 270 then
				UpdatePt(true, amber)
			end
			wait()
		until lt ~= 2
	elseif lt == 3 then
		wait(1 / 6)
		UpdateLt(0.25, blue)
		UpdatePt(true, blue)
		UpdateMt(0, 9e9, 1)
		repeat
			wait()
		until lt ~= 3
	end
end)
