Need tips/ideas for making ordered story event game

Hello, I was wondering if anyone could recommend any ideas or tips for creating efficient/optimized code for a ordered event game? I’m making a horror game and I would like to make player-triggered events occur, but my code that is currently handling the events are all structured mostly in one script and is very hard to read.

For example, you could look at the regular horror games like Midnight Pizza, The Mimic, games whose gameplays are structured to be played through specified events.

For anyone interested, I can provide snippets of the code for feedback on it.

I recommend using promises to help organize it.

Promises help as they can handle race conditions like these whether a player goes to an area first or whether they trigger something secret.