Interger help

I’m making a game that you have to steal a key from a certain person to open a door, but whenever my character walks over to the man, the code resets and he steals the key again. Do you know how to use intergers to only make the code work once? Thanks! =)