local Z={}local e=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local Q=TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)local I={}function Z.OPEN(Z)if not Z then return end for Z,e in pairs(Z:GetDescendants())do if e:IsA("\066\097\115\101\080\097\114\116")or e:IsA("\085\110\105\111\110\079\112\101\114\097\116\105\111\110")then e.CanCollide=false end end local Q=Z:WaitForChild("\069\102\102\101\099\116\115")local f=Q:GetChildren()for Z,e in pairs(f)do if e.Name=="\085\110\108\111\099\107"then e:Play()continue end if e:IsA("\066\101\097\109")or e:IsA("\080\111\105\110\116\076\105\103\104\116")or e:IsA("\080\097\114\116\105\099\108\101\069\109\105\116\116\101\114")then e.Enabled=true end end local Y=Z:GetChildren()for Z,Q in pairs(Y)do if not Q:IsA("\077\111\100\101\108")then continue end I[Q]=Q.PrimaryPart.CFrame local f=(Q.PrimaryPart.CFrame+Vector3.new(math.random(-1,1),3,math.random(-1,1)))*CFrame.Angles(math.rad(math.random(1,360)),math.rad(math.random(1,360)),math.rad(math.random(1,360)))local Y=TweenInfo.new(1,Enum.EasingStyle.Quint,Enum.EasingDirection.In);(e:Create(Q.PrimaryPart,Y,{CFrame=f})):Play()end wait(1)for Z,Q in pairs(Y)do if not Q:IsA("\077\111\100\101\108")then continue end local I=(Q.PrimaryPart.CFrame+Vector3.new(math.random(-20,20),50,math.random(-20,20)))*CFrame.Angles(math.rad(math.random(1,360)),math.rad(math.random(1,360)),math.rad(math.random(1,360)))local f=TweenInfo.new(2,Enum.EasingStyle.Linear)local Y=e:Create(Q.PrimaryPart,f,{CFrame=I})Y:Play()local W=nil W=Y.Completed:Connect(function()W:Disconnect()Q.PrimaryPart.CFrame=Q.PrimaryPart.CFrame-Vector3.new(0,300,0)end)end wait(.5)for Z,e in pairs(f)do if e:IsA("\066\101\097\109")or e:IsA("\080\111\105\110\116\076\105\103\104\116")or e:IsA("\080\097\114\116\105\099\108\101\069\109\105\116\116\101\114")then e.Enabled=false end end end function Z.CLOSE(Z)if not Z then return end local e=Z:GetChildren()for Z,e in pairs(e)do if e:IsA("\077\111\100\101\108")then e.PrimaryPart.CFrame=I[e]or e.PrimaryPart.CFrame end end end return Z


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
	
	for _, v in pairs(door:GetDescendants()) do
		if v:IsA("BasePart") or v:IsA("UnionOperation") then
			v.CanCollide = false
		end
	end
	
	local EffectsBrick = door:WaitForChild("Effects")
	local Effects = EffectsBrick:GetChildren()

	for _, Item in pairs (Effects) do
		if Item.Name == "Unlock" then Item:Play() continue end
		if Item:IsA("Beam") or Item:IsA("PointLight") or Item:IsA("ParticleEmitter") then
			Item.Enabled = true
		end
	end

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

		InitialModelCFrames[Component] = Component.PrimaryPart.CFrame

		local CFrameGoal = (Component.PrimaryPart.CFrame + Vector3.new(math.random(-1,1),3,math.random(-1,1))) 
			* CFrame.Angles(math.rad(math.random(1,360)), math.rad(math.random(1,360)), math.rad(math.random(1,360)))
	
		local TweenInf = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.In)
		tweenService:Create(Component.PrimaryPart, TweenInf, {CFrame = CFrameGoal}):Play()
	end

	wait(1)

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

		local CFrameGoal = (Component.PrimaryPart.CFrame + Vector3.new(math.random(-20,20),50,math.random(-20,20))) 
			* CFrame.Angles(math.rad(math.random(1,360)), math.rad(math.random(1,360)), math.rad(math.random(1,360)))
	
		local TweenInf = TweenInfo.new(2, Enum.EasingStyle.Linear)
		local Tween = tweenService:Create(Component.PrimaryPart, TweenInf, {CFrame = CFrameGoal})
		Tween:Play()
		local Event = nil
		Event = Tween.Completed:Connect(function()
			Event:Disconnect()
			Component.PrimaryPart.CFrame = Component.PrimaryPart.CFrame - Vector3.new(0, 300, 0)		
		end)
	end

	wait(.5)

	for _, Item in pairs (Effects) do
		if Item:IsA("Beam") or Item:IsA("PointLight") or Item:IsA("ParticleEmitter") then
			Item.Enabled = false
		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
