error on spawner and the destroy object does not work

Don’t post code as a wall of plain text, please edit your post to use code-tags . Also, please don’t use every tag you can find on your posts; it has nothing to do with tilemap, 2d physics, performance, documentation etc.

I’ll move your post to the Scripting forum, your problem is not related to any 2D feature.