Help, can code to open new level be made better?

This is my code to enable buttons that allows the player to play the next level.

Can the code be made better? So that I don’t need to make a variable for each level. Or some how bind the level button to the level name?

Hey @ddave104!

So what you can do first is make an array of bools and name each bool for each level. Keep this in the save game. When a level is complete, mark that bool as true.
When you go to load, you can do a “ForEachWithBreak”. Input the list of level bools and the first one that returns true, run the break so it stops iterating over the array and continues your code! You can even make another array of Names for the levels, and then compare the index of the boolean entry that returned true, and use that name for Load Level (meaning you only need one button)! :slight_smile:

Hope that helps, let us know if you need more clarification once you give it a shot!