I am trying to make a game where the character has to jump over boxes in order to reach the end goal. I currently have this logic written out for my box sprite
and it works for the first box sprite (the player cannot walk through the box and is able to land on top of it). However, if I duplicate the sprite and create a second box, only the second box works as expected. Meaning, the player can now walk through the first box which they are not meant to be able to do. I have also tried creating clones of my first box, and adding the logic above to each clone, but the same problem occurs. Is there a way to have this code work for each box sprite I create so that the player is unable to walk through any of the boxes and can jump on top of them? Here is a
link to my project for reference.
It's probably because both are using the exact same variable, and one is overwriting the other. What I would suggest is instead of using variables, use lists, and each clone would have a specified list item for it to put its checks into. So, for example, if you have 5 clones, then the "box touching dino?" would be a list of 5 items, each item representing a box. And instead of just checking if the variable is true, check if the list contains any true values, and use that instead.
Also, instead of using this:
Use this:

It functions the exact same, but takes up less space.
Here's the first way to fix it, from the comment above:
However, I looked at it further, and found a different, better way to do this. Instead of doing collision in the boxes, the dino does the collision, which means that the boxes don't even need to do anything other than appear.
Thank you so much for the help! The first solution you gave works exactly how I wanted.