How to make deleting system

Hi, im making a 3D game, it has a building system that can place blocks, i however don’t know how to make a deleting system. There isn’t any tutorial and i tried making each placable item detect a raycast and delete itself, but that interferes with my building script. Is there anyway to make a deleteing system?

make a UI toggle that switches between two states PLACE/DELETE

now you said your place script is working so when you switch the toggle to delete, stop your script of placing from work and let your delete system to take the role.

// make sure you use layers filter in your raycast to only interact with the placed objects