local n={}DebugEnabled=false Debris=game:GetService("\068\101\098\114\105\115")function n.FracturePart(n)local D=n:FindFirstChild("\066\114\101\097\107\105\110\103\080\111\105\110\116")local i=n:FindFirstChild("\067\111\110\102\105\103\117\114\097\116\105\111\110")local E=false local L=0 local W=false local X=false if DebugEnabled then local n=Instance.new("\080\097\114\116")n.Shape="\066\097\108\108"n.CanCollide=false n.Anchored=true n.Size=Vector3.new(.5,.5,.5)n.Color=Color3.fromRGB(255,0,0)n.Position=D.WorldPosition n.Parent=workspace end local A=n:FindFirstChild("\066\114\101\097\107\083\111\117\110\100")if A then local D=Instance.new("\080\097\114\116")D.Size=Vector3.new(.2,.2,.2)D.Position=n.Position D.Name="\084\101\109\112\111\114\097\114\121\083\111\117\110\100\069\109\105\116\116\101\114"D.Anchored=true D.CanCollide=false D.Transparency=1 local i=A:Clone()i.Parent=D D.Parent=workspace i:Play()Debris:AddItem(D,i.TimeLength)end if i then E=i.DebrisDespawn.Value L=i.DebrisDespawnDelay.Value W=i.WeldDebris.Value X=i.AnchorDebris.Value else warn("\084\104\101 \'\067\111\110\102\105\103\117\114\097\116\105\111\110\' \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114 \111\102 "..(n.Name.."\046 \080\108\101\097\115\101 \105\110\115\101\114\116 \097 \'\067\111\110\102\105\103\117\114\097\116\105\111\110\' \119\105\116\104 \116\104\101 \102\111\108\108\111\119\105\110\103 \118\097\108\117\101\115\059 \'\068\101\098\114\105\115\068\101\115\112\097\119\110\' \040\098\111\111\108\041\044 \'\087\101\108\100\068\101\098\114\105\115\' \040\098\111\111\108\041\044 \'\068\101\098\114\105\115\068\101\115\112\097\119\110\068\101\108\097\121\' \040\110\117\109\098\101\114\047\105\110\116\041"))end if not D then warn("\084\104\101 \'\066\114\101\097\107\105\110\103\080\111\105\110\116\' \097\116\116\097\099\104\109\101\110\116 \105\115 \110\111\116 \097 \118\097\108\105\100 \109\101\109\098\101\114 \111\102 "..(n.Name.."\046 \080\108\101\097\115\101 \105\110\115\101\114\116 \097\110 \097\116\116\097\099\104\109\101\110\116 \110\097\109\101\100 \'\066\114\101\097\107\105\110\103\080\111\105\110\116\'"))end local s=D.Position.Y local p=D.Position.Z local a=Instance.new("\087\101\100\103\101\080\097\114\116")local U=Instance.new("\087\101\100\103\101\080\097\114\116")local P=Instance.new("\087\101\100\103\101\080\097\114\116")local r=Instance.new("\087\101\100\103\101\080\097\114\116")local Q=n:FindFirstChild("\066\114\101\097\107\083\111\117\110\100")a.Material=n.Material a.Color=n.Color a.Transparency=n.Transparency a.Size=n.Size-Vector3.new(0,n.Size.Y/2-s,n.Size.Z/2+p)local j=a.Size.Y local b=a.Size.Z a.CFrame=n.CFrame*CFrame.new(0,s-a.Size.Y/2,p+a.Size.Z/2)a.CFrame=a.CFrame*CFrame.Angles(math.rad(90),0,0)a.Size=Vector3.new(a.Size.X,b,j)local x=a:Clone()x.CFrame=x.CFrame*CFrame.Angles(math.rad(180),0,0)U.Material=n.Material U.Color=n.Color U.Transparency=n.Transparency U.Size=n.Size-Vector3.new(0,n.Size.Y/2+s,n.Size.Z/2+p)U.CFrame=n.CFrame*CFrame.new(0,s+U.Size.Y/2,p+U.Size.Z/2)local h=U:Clone()h.CFrame=h.CFrame*CFrame.Angles(math.rad(180),0,0)P.Material=n.Material P.Color=n.Color P.Transparency=n.Transparency P.Size=n.Size-Vector3.new(0,n.Size.Y/2+s,n.Size.Z/2-p)local d=P.Size.Y local u=P.Size.Z P.CFrame=n.CFrame*CFrame.new(0,s+P.Size.Y/2,p-P.Size.Z/2)P.CFrame=P.CFrame*CFrame.Angles(math.rad(90),0,0)P.Size=Vector3.new(P.Size.X,u,d)local J=P:Clone()J.CFrame=J.CFrame*CFrame.Angles(math.rad(180),0,0)r.Material=n.Material r.Color=n.Color r.Transparency=n.Transparency r.Size=n.Size-Vector3.new(0,n.Size.Y/2-s,n.Size.Z/2-p)r.CFrame=n.CFrame*CFrame.new(0,s-r.Size.Y/2,p-r.Size.Z/2)local Z=r:Clone()Z.CFrame=Z.CFrame*CFrame.Angles(math.rad(180),0,0)local o={a,x;U,h,P,J;r;Z}local m={}local c=nil for D,i in ipairs(o)do table.insert(m,i)if not c then c=i end i.Anchored=X if not X then i.Velocity=n.Velocity i.RotVelocity=n.RotVelocity end if W and c then local n=Instance.new("\087\101\108\100\067\111\110\115\116\114\097\105\110\116")n.Name="\083\104\097\114\100\087\101\108\100"n.Part0=c n.Part1=i n.Parent=i end i.Name="\083\104\097\114\100"i.Parent=n.Parent if E then Debris:AddItem(i,L)end end n:Destroy()return m end return n
-- Version 3
-- Last updated: 31/07/2020

local Module = {}

DebugEnabled = false

Debris = game:GetService("Debris")

function Module.FracturePart(PartToFracture)
	local BreakingPointAttachment = PartToFracture:FindFirstChild("BreakingPoint")

	-- Settings
	local Configuration = PartToFracture:FindFirstChild("Configuration")

	local DebrisDespawn = false
	local DebrisDespawnDelay = 0
	local WeldDebris = false
	local AnchorDebris = false

	if DebugEnabled then
		local DebugPart = Instance.new("Part")
		DebugPart.Shape = "Ball"
		DebugPart.CanCollide = false
		DebugPart.Anchored = true
		DebugPart.Size = Vector3.new(0.5, 0.5, 0.5)
		DebugPart.Color = Color3.fromRGB(255, 0, 0)
		DebugPart.Position = BreakingPointAttachment.WorldPosition
		DebugPart.Parent = workspace
	end

	local BreakSound = PartToFracture:FindFirstChild("BreakSound")

	if BreakSound then
		local SoundPart = Instance.new("Part")
		SoundPart.Size = Vector3.new(0.2, 0.2, 0.2)
		SoundPart.Position = PartToFracture.Position
		SoundPart.Name = "TemporarySoundEmitter"
		SoundPart.Anchored = true
		SoundPart.CanCollide = false
		SoundPart.Transparency = 1
		local Sound = BreakSound:Clone()
		Sound.Parent = SoundPart
		SoundPart.Parent = workspace
		Sound:Play()
		Debris:AddItem(SoundPart, Sound.TimeLength)
	end

	if Configuration then
		DebrisDespawn = Configuration.DebrisDespawn.Value
		DebrisDespawnDelay = Configuration.DebrisDespawnDelay.Value
		WeldDebris = Configuration.WeldDebris.Value
		AnchorDebris = Configuration.AnchorDebris.Value
	else
		warn(
			"The 'Configuration' is not a valid member of "
				.. PartToFracture.Name
				.. ". Please insert a 'Configuration' with the following values; 'DebrisDespawn' (bool), 'WeldDebris' (bool), 'DebrisDespawnDelay' (number/int)"
		)
	end

	if not BreakingPointAttachment then
		warn(
			"The 'BreakingPoint' attachment is not a valid member of "
				.. PartToFracture.Name
				.. ". Please insert an attachment named 'BreakingPoint'"
		)
	end

	local BreakingPointY = BreakingPointAttachment.Position.Y
	local BreakingPointZ = BreakingPointAttachment.Position.Z

	local ShardBottomLeft = Instance.new("WedgePart")
	local ShardBottomRight = Instance.new("WedgePart")
	local ShardTopLeft = Instance.new("WedgePart")
	local ShardTopRight = Instance.new("WedgePart")

	local BreakSound = PartToFracture:FindFirstChild("BreakSound")

	-- Bottom Left
	ShardBottomLeft.Material = PartToFracture.Material
	ShardBottomLeft.Color = PartToFracture.Color
	ShardBottomLeft.Transparency = PartToFracture.Transparency
	ShardBottomLeft.Size = PartToFracture.Size
		- Vector3.new(0, (PartToFracture.Size.Y / 2) - BreakingPointY, (PartToFracture.Size.Z / 2) + BreakingPointZ)
	local OldSizeY = ShardBottomLeft.Size.Y
	local OldSizeZ = ShardBottomLeft.Size.Z
	ShardBottomLeft.CFrame = PartToFracture.CFrame
		* CFrame.new(0, BreakingPointY - (ShardBottomLeft.Size.Y / 2), BreakingPointZ + (ShardBottomLeft.Size.Z / 2))
	ShardBottomLeft.CFrame = ShardBottomLeft.CFrame * CFrame.Angles(math.rad(90), 0, 0)
	ShardBottomLeft.Size = Vector3.new(ShardBottomLeft.Size.X, OldSizeZ, OldSizeY)
	local ShardBottomLeft2 = ShardBottomLeft:Clone()
	ShardBottomLeft2.CFrame = ShardBottomLeft2.CFrame * CFrame.Angles(math.rad(180), 0, 0)

	-- Bottom Right
	ShardBottomRight.Material = PartToFracture.Material
	ShardBottomRight.Color = PartToFracture.Color
	ShardBottomRight.Transparency = PartToFracture.Transparency
	ShardBottomRight.Size = PartToFracture.Size
		- Vector3.new(0, (PartToFracture.Size.Y / 2) + BreakingPointY, (PartToFracture.Size.Z / 2) + BreakingPointZ)
	ShardBottomRight.CFrame = PartToFracture.CFrame
		* CFrame.new(0, BreakingPointY + (ShardBottomRight.Size.Y / 2), BreakingPointZ + (ShardBottomRight.Size.Z / 2))
	local ShardBottomRight2 = ShardBottomRight:Clone()
	ShardBottomRight2.CFrame = ShardBottomRight2.CFrame * CFrame.Angles(math.rad(180), 0, 0)

	-- Top Left
	ShardTopLeft.Material = PartToFracture.Material
	ShardTopLeft.Color = PartToFracture.Color
	ShardTopLeft.Transparency = PartToFracture.Transparency
	ShardTopLeft.Size = PartToFracture.Size
		- Vector3.new(0, (PartToFracture.Size.Y / 2) + BreakingPointY, (PartToFracture.Size.Z / 2) - BreakingPointZ)
	local OldSizeY = ShardTopLeft.Size.Y
	local OldSizeZ = ShardTopLeft.Size.Z
	ShardTopLeft.CFrame = PartToFracture.CFrame
		* CFrame.new(0, BreakingPointY + (ShardTopLeft.Size.Y / 2), BreakingPointZ - (ShardTopLeft.Size.Z / 2))
	ShardTopLeft.CFrame = ShardTopLeft.CFrame * CFrame.Angles(math.rad(90), 0, 0)
	ShardTopLeft.Size = Vector3.new(ShardTopLeft.Size.X, OldSizeZ, OldSizeY)
	local ShardTopLeft2 = ShardTopLeft:Clone()
	ShardTopLeft2.CFrame = ShardTopLeft2.CFrame * CFrame.Angles(math.rad(180), 0, 0)

	-- Top Right
	ShardTopRight.Material = PartToFracture.Material
	ShardTopRight.Color = PartToFracture.Color
	ShardTopRight.Transparency = PartToFracture.Transparency
	ShardTopRight.Size = PartToFracture.Size
		- Vector3.new(0, (PartToFracture.Size.Y / 2) - BreakingPointY, (PartToFracture.Size.Z / 2) - BreakingPointZ)
	ShardTopRight.CFrame = PartToFracture.CFrame
		* CFrame.new(0, BreakingPointY - (ShardTopRight.Size.Y / 2), BreakingPointZ - (ShardTopRight.Size.Z / 2))
	local ShardTopRight2 = ShardTopRight:Clone()
	ShardTopRight2.CFrame = ShardTopRight2.CFrame * CFrame.Angles(math.rad(180), 0, 0)

	local ShardDictionary = {
		ShardBottomLeft,
		ShardBottomLeft2,
		ShardBottomRight,
		ShardBottomRight2,
		ShardTopLeft,
		ShardTopLeft2,
		ShardTopRight,
		ShardTopRight2,
	}

	local shards = {}
	local FirstShard = nil
	for Index, Shard in ipairs(ShardDictionary) do
		table.insert(shards, Shard)

		if not FirstShard then
			FirstShard = Shard
		end
		Shard.Anchored = AnchorDebris
		if not AnchorDebris then
			Shard.Velocity = PartToFracture.Velocity
			Shard.RotVelocity = PartToFracture.RotVelocity
		end
		if WeldDebris and FirstShard then
			local Weld = Instance.new("WeldConstraint")
			Weld.Name = "ShardWeld"
			Weld.Part0 = FirstShard
			Weld.Part1 = Shard
			Weld.Parent = Shard
		end
		Shard.Name = "Shard"
		Shard.Parent = PartToFracture.Parent
		if DebrisDespawn then
			Debris:AddItem(Shard, DebrisDespawnDelay)
		end
	end
	PartToFracture:Destroy()

	return shards
end

return Module
