How would I detect this?

How would I detect the amount of bricks a player exploded when they shot a rocket or dropped a bomb? Lost on if it should be in the bomb or rocket script or its own separate thing.

1 Like

You could check if the bricks were hit by the explosion( you can use explosion.Hit) and use tables or a number value to count.

1 Like
local explosion = Instance.new("Explosion")
explosion.BlastRadius = 20
explosion.Position = script.Parent.OriginPart.Position

explosion.Hit:Connect(function(part, distance)
	if part.Name == "GoldenPart" then
		print("explosion hit a golden part ("..distance.." studs away).")
		part.Color = Color3.new(0, 1, 0)
	end
end)
	
explosion.Parent = game.Workspace

Make sure the BlastRadius of the explosion is large enough, it’s set to 4 by default (which would be too small to detect further parts).

2 Likes

Good solution, notice that he never specified a brick or unique brick. But to count the amount of those hit bricks.

1 Like