LoadCharacter bug

My game attempts to spawn a bunch(30?) of players at the same time. Sometimes the LoadCharacter call can take 3 seconds, and sometimes it can take much longer. I think the problem is with the server requesting all the content for the R15 characters before spawning them. I’ve had it take 60 seconds before to spawn a character, but it usually takes ~3 seconds.

Recently in one of the cases where it took a long time to spawn players, I got this error message in server console:
7YDJDc

This error seems completely out of my control. Here is the code that is the said culprit.
PhDB0g

The code does not seem possible to cause this problem, since it literally checks to make sure that the player parented to players service directly before making the LoadCharacter call.

My assumption is that the LoadCharacter call took so long that the player left while the clientcode was doing it’s thing and then blamed my lua script. Could we get a better error message if this is the case?

Sidenote, does anyone know how I can get players to all spawn simultaneously?

3 Likes

Why are you trying to spawn 30 characters at once? Why not just teleport the old ones to the spawn instead

When using LoadCharacter you don’t have to worry about changes that were made to a character within the current game state such as:

  • Different animations that might still be playing.
  • Altered humanoid states (sitting/ragdolling).
  • Equipped (custom) tools that need to be removed.
  • Inserted character scripts that have no more use.

Basically you don’t have to worry about any clean ups when a character is getting regenerated. With reloading characters you ensure that you will always get a new, clean character hierarchy.

3 Likes

The players don’t have characters to be teleported before then. The game spawns all of the characters at the same time at the beginning of the game. Maybe I could load their characters though, and jam the characters into replicated storage until I am ready to really have spawn.