Help! player characters keep spawning in!

Working on a world selection screen but the game keeps on spawning player characters over and over again! it always happens when i run the command anywhere but “on game start” (ft my wonderful placeholders :3

2 Likes

If you click the menu button and then click on the “show stats” button, you can see that the number of sprites in the project just keeps going up and up forever:



This is because the “On Game Update” loop runs every time the screen updates, which is a lot. It’s basically like a forever loop. Instead of putting your player character creation in a forever loop, which is causing the player to be created over and over and over again, you should run the code in that On Game Update only when the level changes. The solution I like best is putting the code into a function and running that function whenever you change the level, like this:

Now I see that you also have another forever loop running very similar code, so I’m going to move all that into this function as well. Here’s my version of your project:

3 Likes

oohh thank you thank you thank you! to be frank i wasnt very familiar with functions but checking this out i think ive gotten the hang of things thanks!!

1 Like