---------------------------------------------------



This = script.Parent
Elevator = This.Parent.Parent.Parent
CustomLabel = require(This.Parent.Parent.Parent.CustomLabel)
Characters = require(script.Characters)

ArwTime = 0.2

CustomText = CustomLabel["CUSTOMFLOORLABEL"]

Elevator:WaitForChild("Floor").Changed:connect(function(floor)
  --custom indicator code--
  ChangeFloor(tostring(floor))
end)

function ChangeFloor(SF)
	if CustomText[tonumber(SF)] then
		SF = CustomText[tonumber(SF)]
	end
	SetDisplay(1,(string.len(SF) == 2 and SF:sub(1,1) or "NIL"))		
	SetDisplay(2,(string.len(SF) == 2 and SF:sub(2,2) or SF))
end



function SetDisplay(ID,CHAR)
	if This.Display:FindFirstChild("DIG"..ID) and Characters[CHAR] ~= nil then
 		for i,l in pairs(Characters[CHAR]) do 
			for r=1,43 do	
				This.Display["DIG"..ID]["D"..r].Transparency = (l:sub(r,r) == "1" and 0 or 0.95)
			end
		end
	end
end

while wait() do
    if Elevator:WaitForChild("MotorMode").Value ~= "idle" then
	    if Elevator:WaitForChild("Direction").Value == 1 then
			This.Display.ARW1.U1.Transparency = 0.8
			This.Display.ARW1.U2.Transparency = 0.4
			This.Display.ARW1.U3.Transparency = 0
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 0.8
			This.Display.ARW1.U3.Transparency = 0.4
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 0.8
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 0
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 0.4
			This.Display.ARW1.U2.Transparency = 0
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
	    elseif Elevator:WaitForChild("Direction").Value == -1 then
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 0.8
			This.Display.ARW1.D2.Transparency = 0.4
			This.Display.ARW1.D3.Transparency = 0
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 0.8
			This.Display.ARW1.D3.Transparency = 0.4
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 0.8
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 0
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 0.4
			This.Display.ARW1.D2.Transparency = 0
			This.Display.ARW1.D3.Transparency = 1
			wait(ArwTime)
		else
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
	    end
	else
	    if Elevator:WaitForChild("Direction").Value == 1 then
			This.Display.ARW1.U1.Transparency = 0.8
			This.Display.ARW1.U2.Transparency = 0.4
			This.Display.ARW1.U3.Transparency = 0
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
	    elseif Elevator:WaitForChild("Direction").Value == -1 then
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 0.8
			This.Display.ARW1.D2.Transparency = 0.4
			This.Display.ARW1.D3.Transparency = 0
		else
			This.Display.ARW1.U1.Transparency = 1
			This.Display.ARW1.U2.Transparency = 1
			This.Display.ARW1.U3.Transparency = 1
			This.Display.ARW1.D1.Transparency = 1
			This.Display.ARW1.D2.Transparency = 1
			This.Display.ARW1.D3.Transparency = 1
	    end
	end
	
	if Elevator:WaitForChild("Mode").Value ~= "auto" then
		This.Legend.SurfaceGui.Enabled = true
	else
		This.Legend.SurfaceGui.Enabled = false
	end
end