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


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.Light then v:Destroy() end
end
local weld = Instance.new("ManualWeld", This.Button)
weld.C0 = Lift.Car.Platform.CFrame:inverse() * This.Light.CFrame
weld.Part0 = Lift.Car.Platform
weld.Part1 = This.Light
click = false

function ChangeFloor(SF)
	if CustomText[tonumber(SF)] then
		SF = CustomText[tonumber(SF)]
	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 
			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, 0, -0.002),
				}):Play()
				wait(0.1)
				tweenService:Create(weld,TweenInfo.new(0.1),{
					["C1"] = weld.C1*CFrame.new(0, 0, 0.002),
				}):Play()
				wait(0.1)
				click = false
			end
		end)
	end
end
