How do i make a breakable glass

Is there any way to make a physic to the glass
and also when the glass broken , after some while the glass will restore.

4 Likes

You can previously set small pieces of the glass, so when it is broken, the small pieces appear and set them to unanchored so they can move around naturally. After some time, you can remove the small pieces and place back the large piece.

3 Likes

Maybe when item or ray cast hits window it un anchors into glass pieces

This person seemed to have an interesting way to do it:

1 Like

Yes we can actually break the glass with a gun

2 Likes

Listen to other people first I am no scripter so I am just guessing lol

is there more sensible way? cause ı cant understand this

Can you write the example code of breaking physics?

There isn’t any physics in place to break a part into pieces. Someone made a simple fracture module.

When programming something, you need to determine the information you need and the result you want. There are two ways to do this. You can either have the glass break at an exact point (in which case you’d need the point where the glass should break) or you’d just have it break. You also need to know when you want it to break. It make it work with existing code you’re probably going to need to add a humanoid to the glass. Then connect the died event to the break function.

To help us help you, it’d be nice if told us:

  • Your programming experience
  • What you want in more detail
  • Important information (like what you want to break the glass)
1 Like

more detail about of this system?

Does it matter where the glass breaks? When do you want it to respawn? What are you using to break the glass?

There are free models that do this BTW.

I’m no scripter, but I think it’s possible this way:

  1. Start with a big glass piece and some invisible, untouchable wedges of the same color and material.
  2. If the glass piece is touched, destroy the glass piece and make the wedges touchable and unanchored.
    It might work like this:
local GlassPiece = script.Parent
local Wedges = GlassPiece.Parent:GetChildren(GlassWedge)
GlassPiece.Touched:Connect(function()
     GlassPiece:Destroy()
     for i, v in pairs(Wedges) do
          v.Transparency = 0
          v.CanCollide = true
          v.Anchored = false
     end
end)

Anyway, that’s just my two cents.

1 Like

Wow it really makes sense
I didnt thinked this before its more easy and more open.

Howewer how can we break the glass with a gun?

Try changing how the glass breaking function is activated. It will work with projectiles, but likely not with raytracing-based guns.

1 Like

Tiling the part like in that example is probably one of the easiest ways to do it.

You can add a humanoid to the glass model (similar to a character) then connect the died event. That normally works with most free weapons.

can we add a bullet model to the guns and we shoot the bullet model will turn to the enabled mod
and we can add a script that is about when the bullet touched to the glass, then glass will broke

So what you can do is putting the glass into a 3d software, slicing it into pieces, importing the pieces and grouping them so the model looks like a clone of the un-sliced one, and writing a function. For example everytime you click the class the cancollide goes off, the transparency becomes one and the transparency of the pieces becomes 0 and their anchored goes off.

Hold on let me pull the code i used from my gun

1 Like