How do you wait until data & appearance is loaded efficiently?

Whenever I make games I always have this problem:

  • Player doesn’t get morphed
  • Sometimes player data doesn’t load
  • Sometimes a tool is missing from their inventory

What do I need to know? I know you connect a PlayerAdded event, and a CharacterAdded event like this:

game.Players.PlayerAdded:Connect(function(Player)
	if Player.Character then
		-- morph/load data
	end
	Player.CharacterAdded:Connect(function(Character)
		-- morph/load data
	end)
end)

But for some reason this method still isn’t 100% efficient enough for me. If someone with high ping joins the game it may not load all of their character’s data or appearance. I’ve tried using CharacterAppearanceLoaded as well, but the problem persists.

I’ve also tried waiting until character’s parent is no longer nil, but the main problem is I just don’t know how to wait until the data is loaded OR to wait until the players character appearance has loaded.

I believe this is from a flaw of how Roblox handles events, specifically character loading ones. I remember reading up on somebody’s post regarding this, I think it’s on their to-do list to improve/fix.

Basically, sometimes the .CharacterAdded and .CharacterAppearanceLoaded events fire not at necessarily the right time. For example, some parts of the character might not be parented just yet, which leads to a lot of confusion…

What I did was write a bit of hacky bypass, something like this:

Player.CharacterAppearanceLoaded:Connect(function(char)
repeat wait() until char.Parent
end)

And I would use WaitForChild calls as needed. Hopefully this works for you :slight_smile:

2 Likes

I always think of counting the amount of instances in a character then checking to see if the user has that amount. I don’t know though, never tried, seems accurate though.

also maybe you can do something with RunService.Stepped:Wait(), my guess is that, that’s the time between frames.

1 Like

For me, i just send a signal from my (save/load data)script to my (initialization) script
1° - save/load script, send signal to initialization script when the data fully loaded
2° - initialization script run player:LoadCharacter()

any doubts, just ask.