Welcome to the forum @greedy0101! This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!
In the first picture, you defined item, then you tried to find the distance to the item. Below that, you have an if-statement that checks the type of the item. We should take into consideration that the item isn’t necessarily existing, so item might be null, which will give you an error if it’s null.
In the second picture, you made sure the item exists, then you got the distance of the existing item, which eliminated the error. Hope this explains it. If it doesn’t you can ask for more clarification
PS: Please for the next time, put your code as text and formatted as well as it is easier to point out the problem