local V={}local A=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local T=TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut)function V.BREAK(V)if not V then return end V.Transparency=1 local T=V:Clone()T.Transparency=0 T.CanCollide=false T.CanTouch=false T.Massless=true T.Anchored=true local F=script.Smoke:Clone()F.Parent=T T.Parent=workspace.Ignore;(A:Create(T,TweenInfo.new(2,Enum.EasingStyle.Sine,Enum.EasingDirection.In),{Transparency=1})):Play()game.Debris:AddItem(T,2)T.CFrame=V.CFrame local n=V.CFrame.UpVector*(-25-math.random()*10)T.Anchored=false T.Velocity=n+Vector3.new(0,25+math.random()*10,0)T.RotVelocity=Vector3.new(math.random()*20-10,math.random()*20-10,math.random()*20-10)F:Emit(60)end function V.BUILD(V)if not V then return end V.Transparency=1 local T=V:Clone()T.Transparency=1 T.CanCollide=false T.CanTouch=false T.Massless=true local F=script.Smoke:Clone()F.Parent=T local n=script.Sparks:Clone()n.Parent=T T.Parent=workspace.Ignore game.Debris:AddItem(T,3)local j=V.CFrame*CFrame.new(0,-5,0)local s=j-Vector3.new(0,5,0)local y=V.CFrame T.CFrame=s;(A:Create(T,TweenInfo.new(.4,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Position=j.Position})):Play();(A:Create(T,TweenInfo.new(.2),{Transparency=0})):Play()local x=T.Orientation local q=tick()while tick()-q<=.5 do T.Orientation=x+Vector3.new(math.random()*6-3,math.random()*6-3,math.random()*6-3)wait()end;(A:Create(T,TweenInfo.new(.1,Enum.EasingStyle.Cubic,Enum.EasingDirection.In),{CFrame=y})):Play()delay(.1,function()F:Emit(60)n:Emit(30)end)wait(.5)V.Transparency=0 end return V


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
