You just need to indent this line: “body.queue_free()” one tab (or however many spaces you’re indenting)
I’d also check that the other rigidbodies are in group “Bricks” as well.
If the animated sprite is still showing I’d check to see if it is a child of the Rigidbody (the one colliding with the object that has the above script). If it’s not I’d go up enough nodes until you have the entire node structure of the brick destroyed.
An example:
AnimatedSprite
|
|—RigidyBody2D
——|—Collision shape / Collision Polygon
You’d need to call body.get_parent().queue_free() to remove the brick, because the brick’s root node isn’t the RigidBody2D, but rather it’s parent (the animated sprite). I hope that makes sense and helps!