Ah. This is possibly because you're trying to do things across different plays. Once you exit the level, either by dying or finishing it, the Lua environment is reset. Every time you spawn, whether on the midpoint or not, you need to consider your code as executing for the first time. Data isn't retained between plays.acrowdofpeople wrote: So I can make the flag change to a zero or a one successfully, but I can't seem to get the code to do both.
I suggest, if what you're looking to do is essentially create a second checkpoint type thing, you look into the multipoints library, which is designed to manage this kind of eventuality. The default system just creates a checkpoint exactly like a SMBX midpoint, but it does allow further customisation if you have a look at the documentation on the wiki.