local S={}local z=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local m=TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)function S.BREAK(S)if not S then return end S.Transparency=1 local m=S:Clone()m.Transparency=0 m.CanCollide=false m.CanTouch=false m.Massless=true m.Anchored=true local r=script.Smoke:Clone()r.Parent=m m.Parent=workspace.Ignore;(z:Create(m,TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{Transparency=1})):Play()game.Debris:AddItem(m,2)m.CFrame=S.CFrame local Y=S.CFrame.UpVector*(-25-math.random()*10)m.Anchored=false m.Velocity=Y+Vector3.new(0,25+math.random()*10,0)m.RotVelocity=Vector3.new(math.random()*20-10,math.random()*20-10,math.random()*20-10)r:Emit(60)end function S.BUILD(S)if not S then return end S.Transparency=1 local m=S:Clone()m.Transparency=1 m.CanCollide=false m.CanTouch=false m.Massless=true local r=script.Smoke:Clone()r.Parent=m local Y=script.Sparks:Clone()Y.Parent=m m.Parent=workspace.Ignore game.Debris:AddItem(m,3)local O=S.CFrame*CFrame.new(0,-5,0)local G=O-Vector3.new(0,5,0)local I=S.CFrame m.CFrame=G;(z:Create(m,TweenInfo.new(.4,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Position=O.Position})):Play();(z:Create(m,TweenInfo.new(.2),{Transparency=0})):Play()local R=m.Orientation local B=tick()while tick()-B<=.5 do m.Orientation=R+Vector3.new(math.random()*6-3,math.random()*6-3,math.random()*6-3)wait()end;(z:Create(m,TweenInfo.new(.1,Enum.EasingStyle.Cubic,Enum.EasingDirection.In),{CFrame=I})):Play()delay(.1,function()r:Emit(60)Y:Emit(30)end)wait(.5)S.Transparency=0 end return S
--This module is for any client FX related to the Lab's door

local WoodenBarrierFX = {}

local tweenService = game:GetService("TweenService")

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

function WoodenBarrierFX.BREAK(plank)
	if not plank then
		return
	end

	plank.Transparency = 1
	local plankClone = plank:Clone()
	plankClone.Transparency = 0
	plankClone.CanCollide = false
	plankClone.CanTouch = false
	plankClone.Massless = true
	plankClone.Anchored = true

	local smoke = script.Smoke:Clone()
	smoke.Parent = plankClone

	plankClone.Parent = workspace.Ignore
	tweenService
		:Create(plankClone, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.In), { Transparency = 1 })
		:Play()
	game.Debris:AddItem(plankClone, 2)

	plankClone.CFrame = plank.CFrame

	local velo = plank.CFrame.UpVector * (-25 - math.random() * 10)
	plankClone.Anchored = false
	plankClone.Velocity = velo + Vector3.new(0, 25 + math.random() * 10, 0)
	plankClone.RotVelocity = Vector3.new(math.random() * 20 - 10, math.random() * 20 - 10, math.random() * 20 - 10)
	smoke:Emit(60)
end

function WoodenBarrierFX.BUILD(plank)
	if not plank then
		return
	end

	plank.Transparency = 1
	local plankClone = plank:Clone()
	plankClone.Transparency = 1
	plankClone.CanCollide = false
	plankClone.CanTouch = false
	plankClone.Massless = true

	local smoke = script.Smoke:Clone()
	smoke.Parent = plankClone
	local sparks = script.Sparks:Clone()
	sparks.Parent = plankClone

	plankClone.Parent = workspace.Ignore
	game.Debris:AddItem(plankClone, 3)

	local midCf = plank.CFrame * CFrame.new(0, -5, 0)
	local startCf = midCf - Vector3.new(0, 5, 0)
	local endCf = plank.CFrame

	plankClone.CFrame = startCf
	tweenService
		:Create(
			plankClone,
			TweenInfo.new(0.4, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
			{ Position = midCf.Position }
		)
		:Play()
	tweenService:Create(plankClone, TweenInfo.new(0.2), { Transparency = 0 }):Play()
	local originOrientation = plankClone.Orientation

	local start = tick()
	while tick() - start <= 0.5 do
		plankClone.Orientation = originOrientation
			+ Vector3.new(math.random() * 6 - 3, math.random() * 6 - 3, math.random() * 6 - 3)
		wait()
	end

	tweenService
		:Create(plankClone, TweenInfo.new(0.1, Enum.EasingStyle.Cubic, Enum.EasingDirection.In), { CFrame = endCf })
		:Play()
	delay(0.1, function()
		smoke:Emit(60)
		sparks:Emit(30)
	end)
	wait(0.5)

	plank.Transparency = 0
end

return WoodenBarrierFX
