local h={}DebugEnabled=false Debris=game:GetService("\068\101\098\114\105\115")function h.FracturePart(h)local f=h:FindFirstChild("\066\114\101\097\107\105\110\103\080\111\105\110\116")local j=h:FindFirstChild("\067\111\110\102\105\103\117\114\097\116\105\111\110")local H=false local B=0 local u=false local F=false if DebugEnabled then local h=Instance.new("\080\097\114\116")h.Shape="\066\097\108\108"h.CanCollide=false h.Anchored=true h.Size=Vector3.new(.5,.5,.5)h.Color=Color3.fromRGB(255,0,0)h.Position=f.WorldPosition h.Parent=workspace end local d=h:FindFirstChild("\066\114\101\097\107\083\111\117\110\100")if d then local f=Instance.new("\080\097\114\116")f.Size=Vector3.new(.2,.2,.2)f.Position=h.Position f.Name="\084\101\109\112\111\114\097\114\121\083\111\117\110\100\069\109\105\116\116\101\114"f.Anchored=true f.CanCollide=false f.Transparency=1 local j=d:Clone()j.Parent=f f.Parent=workspace j:Play()Debris:AddItem(f,j.PlaybackSpeed)end if j then H=j.DebrisDespawn.Value B=j.DebrisDespawnDelay.Value u=j.WeldDebris.Value F=j.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 "..(h.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 f 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 "..(h.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 V=f.Position.Y local W=f.Position.Z local s=Instance.new("\087\101\100\103\101\080\097\114\116")local D=Instance.new("\087\101\100\103\101\080\097\114\116")local S=Instance.new("\087\101\100\103\101\080\097\114\116")local v=Instance.new("\087\101\100\103\101\080\097\114\116")local l=h:FindFirstChild("\066\114\101\097\107\083\111\117\110\100")s.Material=h.Material s.Color=h.Color s.CanCollide=false s.Transparency=h.Transparency s.Size=h.Size-Vector3.new(0,h.Size.Y/2-V,h.Size.Z/2+W)local r=s.Size.Y local L=s.Size.Z s.CFrame=h.CFrame*CFrame.new(0,V-s.Size.Y/2,W+s.Size.Z/2)s.CFrame=s.CFrame*CFrame.Angles(math.rad(90),0,0)s.Size=Vector3.new(s.Size.X,L,r)local k=s:Clone()k.CFrame=k.CFrame*CFrame.Angles(math.rad(180),0,0)D.Material=h.Material D.Color=h.Color s.CanCollide=false D.Transparency=h.Transparency D.Size=h.Size-Vector3.new(0,h.Size.Y/2+V,h.Size.Z/2+W)D.CFrame=h.CFrame*CFrame.new(0,V+D.Size.Y/2,W+D.Size.Z/2)local C=D:Clone()C.CFrame=C.CFrame*CFrame.Angles(math.rad(180),0,0)S.Material=h.Material S.Color=h.Color s.CanCollide=false S.Transparency=h.Transparency S.Size=h.Size-Vector3.new(0,h.Size.Y/2+V,h.Size.Z/2-W)local z=S.Size.Y local Q=S.Size.Z S.CFrame=h.CFrame*CFrame.new(0,V+S.Size.Y/2,W-S.Size.Z/2)S.CFrame=S.CFrame*CFrame.Angles(math.rad(90),0,0)S.Size=Vector3.new(S.Size.X,Q,z)local G=S:Clone()G.CFrame=G.CFrame*CFrame.Angles(math.rad(180),0,0)v.Material=h.Material v.Color=h.Color s.CanCollide=false v.Transparency=h.Transparency v.Size=h.Size-Vector3.new(0,h.Size.Y/2-V,h.Size.Z/2-W)v.CFrame=h.CFrame*CFrame.new(0,V-v.Size.Y/2,W-v.Size.Z/2)local x=v:Clone()x.CFrame=x.CFrame*CFrame.Angles(math.rad(180),0,0)local O={s;k;D;C;S;G;v,x}local J=nil for f,j in ipairs(O)do if not J then J=j end j.Anchored=F if not F then j.Velocity=h.Velocity j.RotVelocity=h.RotVelocity end if u and J then local h=Instance.new("\087\101\108\100\067\111\110\115\116\114\097\105\110\116")h.Name="\083\104\097\114\100\087\101\108\100"h.Part0=J h.Part1=j h.Parent=j end j.Name="\083\104\097\114\100"j.Parent=h.Parent if H then Debris:AddItem(j,B)end end h:Destroy()end return h
-- 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.PlaybackSpeed)
	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.CanCollide = false
	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
	ShardBottomLeft.CanCollide = false
	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
	ShardBottomLeft.CanCollide = false
	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
	ShardBottomLeft.CanCollide = false
	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 FirstShard = nil
	for Index, Shard in ipairs(ShardDictionary) do
		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()
end

return Module
