Im probably doing something wrong. Im trying to make items place a block on the closest air block after 3 minutes of being on the ground, and then use /kill on themselves. I got this working with a function, but it was laggy. I want to do it with a server script, but I cant find documentation for most aspects of what Im trying to do (server.tick, timer, item entity lifespan, check y position and relative blocks, etc) currently I have what is in the image attached.
This doesnt work. The current non working code was from a tutorial zip, so I currently only understand it somewhat. It doesnt change the scoreboard when it should, every second


