--This module is for any client FX related to the lab debris


local DoorFX = {}

local tweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)



local InitialModelCFrames = {}

function DoorFX.OPEN(door)
	if not door then return end

	local TweenInf = TweenInfo.new(.5, Enum.EasingStyle.Linear)

	door.PurchaseDoor.Sound:Play()

	local Components = door:GetChildren()
	for _, Component in pairs (Components) do
		if not Component:IsA("Model") then continue end

		local descendants = Component:GetChildren()
		for _, item in pairs (descendants) do
			if item:IsA("BasePart") then
				coroutine.wrap(function()
					tweenService:Create(item, TweenInf, {Transparency = 1}):Play()
				end)()
			end
		end
	end
end

function DoorFX.CLOSE(door)
	if not door then return end

	local Components = door:GetChildren()
	for _, Component in pairs (Components) do
		if Component:IsA("Model") then
			Component.PrimaryPart.CFrame = InitialModelCFrames[Component] or Component.PrimaryPart.CFrame 
			--this errors when the module is called for some reason so thats why its like that
		end
	end
end

return DoorFX
