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


local tweenService = game:GetService("TweenService")
This = script.Parent
Lift = This.Parent.Parent.Parent
CustomLabel = require(Lift.CustomLabel)
Characters = require(script.Characters)

CustomText = CustomLabel["CUSTOMFLOORLABEL"]

for i,v in pairs(Lift.Car:WaitForChild("Welds"):GetChildren()) do
	if v.Part1 == script.Parent.Back then v:Destroy() end
end
local weld = Instance.new("ManualWeld", This.Button)
weld.C0 = Lift.Car.Platform.CFrame:inverse() * This.Back.CFrame
weld.Part0 = Lift.Car.Platform
weld.Part1 = This.Back
click = false

function ChangeFloor(SF)
	if CustomText[tonumber(SF)] then
		SF = CustomText[tonumber(SF)]
	end
	if string.len(SF) == 1 then
		This.Label.DIG1.Mesh.Offset = Vector3.new(0, 0, 0)
		This.Label.DIG2.Mesh.Offset = Vector3.new(0.03, 0, 0)
	else
		This.Label.DIG1.Mesh.Offset = Vector3.new(0, 0, 0)
		This.Label.DIG2.Mesh.Offset = Vector3.new(0, 0, 0)
	end
	SetLabel(1,(string.len(SF) == 2 and SF:sub(1,1) or "NIL"))		
	SetLabel(2,(string.len(SF) == 2 and SF:sub(2,2) or SF))
end



function SetLabel(ID,CHAR)
	if This.Label:FindFirstChild("DIG"..ID) and Characters[CHAR] ~= nil then
 		for i,l in pairs(Characters[CHAR]) do 
			if CHAR == "1" or CHAR == "2" or CHAR == "3" or CHAR == "4" or CHAR == "5" or CHAR == "6" or CHAR == "7" or CHAR == "8" or CHAR == "9" or CHAR == "0" then
				This.Label["DIG"..ID].Mesh.Scale = Vector3.new(0.02, 0.11, 0.023)
			elseif CHAR == "+" or CHAR == "-" or CHAR == "#" or CHAR == "." or CHAR == "*" then
				This.Label["DIG"..ID].Mesh.Scale = Vector3.new(0.02, 0.07, 0.023)
			else
				This.Label["DIG"..ID].Mesh.Scale = Vector3.new(0.02, 0.16, 0.03)	
			end
			This.Label["DIG"..ID].Mesh.MeshId = "rbxassetid://"..l
		end
	end
end

ChangeFloor(This.Name)

for x,x in pairs(This.Button:GetChildren()) do 
	if x:IsA("SurfaceGui") and x.Name == ("Button") then 
		x.Button.MouseButton1Click:connect(function()
			if click == false then
				click = true
				tweenService:Create(weld,TweenInfo.new(0.1),{
					["C1"] = weld.C1*CFrame.new(0.002, 0, 0),
				}):Play()
				wait(0.1)
				tweenService:Create(weld,TweenInfo.new(0.1),{
					["C1"] = weld.C1*CFrame.new(-0.002, 0, 0),
				}):Play()
				wait(0.1)
				click = false
			end
		end)
	end
end
