This glass breaking script only breaks when any object touches it, because it is onTouch. How ever how would i make it were a specific object touches it that is located in the workspace, like the baseplate?
local Glass = script.Parent local DecalBack = Glass["BackD"] local DecalFront = Glass["FrontD"] local TextureId = Glass.Texture local broken = false function onTouched() if broken == false then broken = true DecalBack.Texture = TextureId.Value DecalFront.Texture = TextureId.Value elseif broken == true then local g1 = Instance.new("Part") g1.formFactor = "Plate" g1.Size = Vector3.new(1, 0.2, 1) g1.Parent = Glass.Parent g1.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g1.BrickColor = Glass.BrickColor local g2 = Instance.new("Part") g2.formFactor = "Plate" g2.Size = Vector3.new(1, 0.2, 1) g2.Parent = Glass.Parent g2.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g2.BrickColor = Glass.BrickColor local g3 = Instance.new("Part") g3.formFactor = "Plate" g3.Size = Vector3.new(1, 0.2, 1) g3.Parent = Glass.Parent g3.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g3.BrickColor = Glass.BrickColor local g4 = Instance.new("Part") g4.formFactor = "Plate" g4.Size = Vector3.new(1, 0.2, 1) g4.Parent = Glass.Parent g4.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g4.BrickColor = Glass.BrickColor local g5 = Instance.new("Part") g5.formFactor = "Plate" g5.Size = Vector3.new(1, 0.2, 1) g5.Parent = Glass.Parent g5.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g5.BrickColor = Glass.BrickColor local g6 = Instance.new("Part") g6.formFactor = "Plate" g6.Size = Vector3.new(1, 0.2, 1) g6.Parent = Glass.Parent g6.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g6.BrickColor = Glass.BrickColor local g7 = Instance.new("Part") g7.formFactor = "Plate" g7.Size = Vector3.new(1, 0.2, 1) g7.Parent = Glass.Parent g7.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g7.BrickColor = Glass.BrickColor local g8 = Instance.new("Part") g8.formFactor = "Plate" g8.Size = Vector3.new(1, 0.2, 1) g8.Parent = Glass.Parent g8.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g8.BrickColor = Glass.BrickColor local g9 = Instance.new("Part") g9.formFactor = "Plate" g9.Size = Vector3.new(1, 0.2, 1) g9.Parent = Glass.Parent g9.Position = Glass.Position + Vector3.new(math.random(-5,5),math.random(-5,5),math.random(-5,5)) g9.BrickColor = Glass.BrickColor Glass:remove() wait(10) g1:remove() g2:remove() g3:remove() g4:remove() g5:remove() g6:remove() g7:remove() g8:remove() g9:remove() end end Glass.Touched:connect(onTouched)
There are a few ways you could do this. You would need a parameter on your function such as "Hit" because you need to check what hits the object.
if hit.ClassName == "Class" then -- What you want to happen end
if hit:IsA("Class") then print("Working) end
if hit.Name == "NameHere" then print("Hello World!" end
if hit:IsA("Class") or hit.Name == "NameHere" then print("Hope this works for you!" end
If that does not work then I don't know. Anyway hope this helps you achieve your goal!