I ran into some issues yesterday while assigning click events in a loop. I was referred to https://framer.com/getstarted/programming/#scope by mamezito on Slack, and so I solved my issue using "do".
After some tinkering (no idea what I was doing lol), it actually worked. So I've begun reading further and looking into scope and closures.
I'm wondering (when you can't use 'this') which is the best approach: using 'do' or how I've done in this framer file (dunno what you'd call it): http://share.framerjs.com/bxmgg3yblzrv/
To help you out with this, Framer passes the clicked layer inside the event, so you can write your event inside of the for loop. You can use the clicked layer variable to set the background color. Check out this example → http://share.framerjs.com/ufokwjbcdr7d/