Calling LoadCharacter in batch on multiple players causes missing appearances

Describe the bug. Describe what is happening when the bug occurs. Describe what you would normally expect to occur.
The bug happens every time I play the game, it can be seen here:


None of these people’s avatars are actually naked, but when I respawn them they go naked.

How often does the bug happen (Everytime/sometimes/rarely)? What are the steps that reproduce the bug? Please list them in very high detail. Provide simple example places that exhibit the bug and provide a description of what you believe should be the behaviour.

In my game players are respawned quite frequently, every time they get the answer wrong they are respawned using player:LoadCharacter(). This seems to only be happening when a lot of people are spawned all at once. This is the code I use for that, pretty basic:

script.Parent.Touched:Connect(function(prt)
	if prt.Parent:FindFirstChildOfClass("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(prt.Parent)
		plr:LoadCharacter()
	elseif prt.Anchored == false then
		prt.CanCollide = false
	end
end)

Where does the bug happen (www, gametest, etc) Is it level-specific? Is it game specific? Please post a link to the place that exhibits the issue.
This bug happens in any game where loadcharacter is called lots of times in a small time period.

Would a screenshot or video help describe it to someone? If so, post one.


image
image

When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke.
This has always been happening

It is likely caused by the fact that the server can’t load all of the clothes fast enough? But players remain clotheless for the rest of the time they’re alive, they never load until they reset.

Thanks to @SilentBuddy I’ve learnt that this is likely caused by calling LoadCharacter() too frequently, I’ll try and fix this by making it get called locally and adding a debounce.

I’ll put this as the solution if it works.

Edit: Just realised LoadCharacter can only be called server side

3 Likes

Fixed this by changing FallenPartsDestroyHeight to the height I want players to die at, this seems to be working, but if you were to want to do this in a situation where players would be below that height at different points on the map it’s not really a viable solution.

4 Likes

I’m not following. Are you saying you were somehow spawning players UNDER the “FallenPartsDestroyHeight”? How were you accomplishing this without the character being destroyed each time?

In the original post? No, I was just respawning the players; in the game the players are supposed to be respawned when they fall into a sort of lava pit which opens when they get an answer wrong, every time they touched that part I called LoadCharacter which seems to result in no clothing when called lots of times in a short period of time.

The solution that I used was to set the fallenpartsdestroyheight property of workspace to a height just above the lava so that players are automatically removed by the core scripts when they fall into the lava due to being below that height.

Okay so what you were doing could be summarized as:

  • Players would Fall Into Lava
  • Lava would Trigger “LoadCharacter”
  • Occasionally the load character would respawn them Naked?

And you fixed the bug by essentially killing the players before respawning them? Sounds like circumventing a bug on our end. I’ll check it out.

2 Likes

This was happening in my game a few months ago,

I got multiple reports on my discord server about people spawning in with no clothes (all the reports were within a short time period). I can’t remember if I did anything to fix the issue, or if it just fixed itself, but it no longer happens anymore. I’ll try looking through the chat history of the discord to see if I posted anything about fixing the bug.

I wasn’t using the LoadCharacter() event though, So this might have been an unrelated issue

2 Likes

Yeah It’s definitely circumventing a bug in the corescripts, it seems like the appearances of multiple characters can’t be loaded in a very short time period, so either it just gives up on loading their clothing immediately or after some amount of time has passed it gives up and doesn’t load the clothes.

Also, I don’t respawn the player as well as them dying from the FallenPartsDestroyHeight as I no longer have any need to respawn the players, when they die they automatically respawn onto the SpawnLocations

Repeatedly calling LoadCharacter on multiple players within a small timeframe results in players respawning naked. This is very annoying for my game, as players always have to reset to stop themselves exposing private areas.

This can be replicated by calling LoadCharacter on every player in a game at once (Or within about a 10-20 second period). I would assume this bug is likely caused by some kind of timing out in the core scripts on preloading assets?

3 Likes

I’ve run some tests on this to see what it could be caused by, using testing loadcharater.rbxl (557.1 KB).
Here is what I’ve come up with:

100 Respawns, 0.35 Seconds to allow for loading and 30 parts created per respawn, with previous parts not being removed

From the below screenshots you can see that clothing only loaded in 24% of the time, the other 76% was where characters loaded without clothing.


image

100 Respawns, 2 Seconds to allow for loading and 30 parts created per respawn, with previous parts not being removed

As I thought the previous test could have been caused by the short time allowed to wait for the clothing to load, I retried this with a 2 second interval between each reload, as can be seen, the results were very similar.

image
image

10 Respawns, 2 Seconds to allow for loading and 10 parts created per respawn, with previous parts not being removed

To test the hypothesis that this is caused by lag, I reduced the part number per respawn, and the sample size was reduced merely because I think it still displays an accurate result.

image
image

100 Respawns, 1 Second to allow for loading and NO parts created per respawn

Weirdly, I got similar results with this, even though no parts were being created per respawn:

image
image

It’s important to note that the number of re-spawns is per player, the true number of re-spawns can be seen in the final output of these.

It seems that this happens with or without lag, it’s just when players are reloaded frequently with little time between each LoadCharacter.

Hi, any updates on this?

I understand updates take time, but if this is being worked on could someone post here? This really needs to be fixed for the sake of my game’s user experience so just to make sure.

1 Like

Why don’t you teleport the players back to spawn instead of respawning them entirely? That should get you around this problem in the mean-time.

The reason I don’t do this is because LoadCharacter removes anything that the ‘minigame’ they have just been in has given them, for most of my scripts to work the player needs to get a new character that is missing these previously added things, plus I don’t want players ending up with swords in the lobby (though they wont do damage unless in the play area).

To get around this I could code my own system that removes all of the things I’ve added to their character and their tools, but I’m sort of stuck in this position of wanting to work on important game features, and thinking that this will be fixed soon so coding a whole system like that isn’t worth it. (Since I’m not actively advertising this game for large amounts and the player count is usually <10)

Next week, I will be turning on a fix that should address the case where multiple calls LoadCharacter in quick succession can cause some assets not to load correctly on the character. Hopefully, this will address your issue.

3 Likes

This sounds great! I really hope this solves my issue, and I think it probably will, thank you for the response :slight_smile:

(I’ll mark this as solution for now and see what happens)

Hi, has this been turned on yet? My game is still experiencing the same problems :frowning:

Although they may perhaps be slightly less frequent.

This has been enabled. If you are still seeing missing appearances, please let us know.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.