Change color of word on click

Hi,
I’m building a recognition task in which the participants get 20 words on a screen and have to click on the 10 they recognise. Now, because they are all kinda similar I would like the ones that have been clicked on to change colour (from white to black) so the participants know what they have chosen so far.
the experiment has 20 texts called word1-20 which are spread out on the screen and one mouse response called mouse1. I’ve tried two things:
1.

in Each Frame:
 if mouse1.isPressedIn(word2):
    word2.color = 'black'
elif mouse1.isPressedIn(word3):
    word3.color = 'black'
elif mouse1.isPressedIn(word4):
    word4.color = 'black'

this does not work at all.
2.

`Begin Routine:
click_on = False
Each Frame:
if mouse1.isPressedIn(word1):
    if not click_on:
        click_on = True
        click_on = t
        word1.color = 'black'
    else :
        click_on = t
if click_on and t - click_on > 0.15:
    click_on = False
    word1.color = 'white'
End Routine:
word1.color = 'black'

which does work, but I can’t figure out how to use it for more than one word, because doing the same code for more than one word doesn’t work (just changes the colour of the first one, not the next ones).

please help!

You could read through this thread:

but if your code works for one stimulus and not others, this is probably due to a conflict between the code and the settings in the stimulus component. e.g. if it is set to update on very frame, that change may override the change in your code. The stimulus component colour should be set to be constant, or to update at the beginning of every routine.

changing the settings worked great, thank you