How to make a part shattering script

The best way to do it depends on whether that part is anchored (not moving) or not anchored (moving).

If anchored, have all the ‘pieces’ in a model, just iterate over the model and unachor each piece.

If not achored, then the pieces should be welded. Just destroy the welds.

Generally, something most people does with shatter is have a full piece that’s visible, and when it’s time to shatter, hide that piece and show the pieces (before doing what I stated above)