FragmentSmasher - Window/other object obliterator Module

Hello everyone! I noticed that there are posts about the destruction of windows, but no open sourced code or modules I could find on the subject. So, I created FragmentSmasher, a simple module with one function for the destruction of windows and other things.

The module contains one useful function,BreakSurface(), for breaking apart a square/rectangular shaped part. It works by taking the original part, and replacing it with a multitude of triangles of the same total size.


FragmentSmasher= require(game.ServerStorage.FragmentSmasher)


	-Pane- the Part you want to effect
	-BreakOriginPositionVector- the center of destruction, and the middle point of the calculations
	-DirectionalVelocityVector- a direction Vector3 that determines the general direction for the fragments to fly toward(Pass the string "Default" to use the Default vector)
	-SoundId- the SoundId to be played on smash(Pass the string "None" to use no Sound)
	-DestroyTime- the amount of time that passes before the fragments are deleted from the workspace(Pass the string "Never" for the fragments to exist for a infinite amount of time)
Basic Usage:


FragmentSmasher= require(game.ServerStorage.FragmentSmasher)


This code is a basic example of how to break a window, or other object.


Gun Example:

Example Code:

FragmentSmasher = require(game.ServerStorage.FragmentSmasher)

local Gun = "gun"
MouseHit = "mouse hit position"
function OnShoot()
    local ray =, (MouseHit - Gun.Barrel.Position).unit * 300)

    local part, position = workspace:FindPartOnRayWithIgnoreList(ray, {Gun})

    if part.Name == "Window" then
            Gun.Barrel.CFrame.LookVector * 75 +, 25, 0),

This basic example creates a Ray, which it then uses to find the position the Ray hit, and the part the Ray hit. If the part is named “Window”,it fires the module’s BreakSurface() function with a BreakOriginPositionVector of the Ray hit position, and a DirectionalVelocityVector that faces away from the shotgun. This results in something similar to the following I created.


Fun, right?

Keep in mind that the long sides of your window must be the X and Y axis, otherwise the calculations will not work properly.

Link to obtain:

Enjoy! :grinning:


Cool module

There’s an error though
You should probably fix this

I think you meant to write “FragmentSmasher” instead of “FaceSmasher”
It works fine once you change that


Thank you so much for pointing this out! I fixed before I released the module, but must have forgotten to publish the fix. Thanks again.

Problem Resolved


Is it possible able to cut like a lightsaber on the metal or door?

1 Like

This module is more for completely destroying a part, not really making precise cuts.

However you could probably make a system similar to mine, that works by dividing a single part into many smaller parts. You would just have to use more parts the more detail you want. I created the module to be very understandable, so you should be able to modify it to help you in that way.

DM me if you have further questions, or would like some more guidance, and I would be happy to help out to the best of my ability!

1 Like

Ah okay but did it use unions or just only parts? If it parts hopefully I’ll try see what I can do with it but for union it hard since it have limited

It uses just parts. It works by taking the original dimensions of the part, and subdividing it into smaller parts inside of it. It you used it on a union it would just make rectangular sections with similar dimensions to the union, but not take on the unions shape. Making it work with unions would be much harder, because union calculations take a excruciatingly long time to process, and the delay would be very long.


Ah okay thank you for answer it.

Really epic module with an even epicer concept!
Nice contribution! :smile:

1 Like

I’ve tried shooting at a part with this module but nothing happens. The part doesn’t divide and break when I shoot at it.

This is most likely due to a misuse of the module. Can you send me your current code in DMs, so I can try to help you figure it out?

I have a question, on some materials, (corroded metal and concrete in my case), it turns to colorless plastic.

how do I fix it? Its fine for glass.

I just tried it myself and experienced the same problem. I pushed an update to the module that should fix the problem. Grab a new copy and it should be working properly.

1 Like

Ok thank you for fixing it! Glad you are still updating it!

Hi. I recently used this module in one of my projects. As part of the project, I needed to be able to smash objects that aren’t oriented along the X-Y plane. As a result, I now have code, which at least re-positions the quadrants to match the pane that is being destroyed. In the spirit of the original module, I believe it should be made available, and so I am including the function below. (I also attempted to change the orientation of the quadrants, but I have been unable to verify if this has worked)

function Rotate_Quadrant(Quadrant,Pane)
	-- get CFrame values
	local x, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33 = Quadrant.CFrame:components()
	local orientation = Pane.Orientation
	local center = Pane.Position
	-- convert x, y, z to offsets
	x -= center.X
	y -= center.Y
	z -= center.Z
	-- rotate in the Y-Axis
	local angle = orientation.Y*2*math.pi/360
		-- position
	x, z = x*math.cos(angle)+z*math.sin(angle), z*math.cos(angle)-x*math.sin(angle) 
		-- angles
	m11, m13 = m11*math.cos(angle)+m13*math.sin(angle), m13*math.cos(angle)-m11*math.sin(angle) 
	m21, m23 = m21*math.cos(angle)+m23*math.sin(angle), m23*math.cos(angle)-m21*math.sin(angle) 
	m31, m33 = m31*math.cos(angle)+m33*math.sin(angle), m33*math.cos(angle)-m31*math.sin(angle) 
	-- repeat for X-Axis, then Z-Axis	
	angle = orientation.X*2*math.pi/360
	y, z = y*math.cos(angle)-z*math.sin(angle), z*math.cos(angle)+y*math.sin(angle)
	m12, m13 = m12*math.cos(angle)-m13*math.sin(angle), m13*math.cos(angle)+m12*math.sin(angle) 
	m22, m23 = m22*math.cos(angle)-m23*math.sin(angle), m23*math.cos(angle)+m22*math.sin(angle) 
	m32, m33 = m32*math.cos(angle)-m33*math.sin(angle), m33*math.cos(angle)+m32*math.sin(angle)  
	angle = orientation.Z*2*math.pi/360
	x, y = x*math.cos(angle)-y*math.sin(angle), y*math.cos(angle)+x*math.sin(angle)
	m11, m12 = m11*math.cos(angle)-m12*math.sin(angle), m12*math.cos(angle)+m11*math.sin(angle) 
	m21, m22 = m21*math.cos(angle)-m22*math.sin(angle), m22*math.cos(angle)+m21*math.sin(angle) 
	m31, m32 = m31*math.cos(angle)-m32*math.sin(angle), m32*math.cos(angle)+m31*math.sin(angle)  
	-- Convert the offsets back into world coordinates
	x += center.X
	y += center.Y
	z += center.Z
	-- rebuild the CFrame
	Quadrant.CFrame =, y, z, m11, m12, m13, m21, m22, m23, m31, m32, m33)

I hope someone finds this helpful in the future.


Actual life saver dude. I’ve been struggling with this for hours. Thank you so much!


Did this function ever work for you? It doesn’t seem to work for me. Thanks in advance

1 Like

Yea works like a charm. Only one small issue which is that if a structure is angled a specific way when the wall breaks the debris will be very big.

1 Like

Cool module! You should add the ability to determine how many parts the window breaks into. Like for example, if someone wants it so break into small tiny pieces they can have a high number of pieces, bit of they want bigger fragments then they can have a lower number of fragments!

I will most likely be using this! Nice work!

how do you get the script to work with a gun? Do i put the script within a tool? This does work normally for me but I can’t figure out how to do it with a gun.