How to check if player is fully loaded?

Hi, I was looking for answer on many other posts but id didn’t work. I checked HasApperanceLoaded and CharacterAppearanceLoaded.
I want to teleport two first players somewhere right after they join server. I can’t put there wait(x) command because if they leave my script will crush.

Here is main part of script (variable “stats” is set in other script when player join game)

	while true do
		wait(0.1)
		local number = 0
		plrs = game.Players:GetChildren()
		for idx,val in pairs(plrs) do
			if val:FindFirstChild("PlayerGui") and val:FindFirstChild("Backpack") and val:FindFirstChild("StarterGear") and val:FindFirstChild("stats") and val.Character then
				if val.Character:FindFirstChild("HumanoidRootPart") and val:HasAppearanceLoaded() then
					number += 1
				end
			end
		end
		if number >= 2 then
			print("gooo")
			break
		end
	end
1 Like

I think putting that inside a while loop would be a bit inefficient. You could use the Player.CharacterAdded and then wait for every children to be loaded with ContentProvider, or use a for loop to go through every player and wait for their character to load in

local ContentProvider = game:GetService("ContentProvider");

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		ContentProvider:PreloadAsync(character:GetChildren()); -- This will yield (pause the code) until the given parts are all loaded in
	end)
end)

-- Or

local plrs = game.Players:GetPlayers();
local ContentProvider = game:GetService("ContentProvider");

for _, p in pairs(plrs) do
	ContentProvider:PreloadAsync(p.Character:GetChildren());
end

Alternatively, you could use game.Loaded in a local script and store a “loaded” bool value inside the player’s character or backpack.
Hope this helps

3 Likes
if not game.Loaded then
      game.Loaded:Wait()
end

Thanks sir!
It worked perfect :slight_smile:

1 Like