How to check if a model has fully loaded

  1. What do you want to achieve? Keep it simple and clear!

So basically. I have a round script that teleports players to a map. But i noticed that sometimes the map hasnt fully loaded which causes the players to fall out of the map. I did some research and found some stuff. But none managed to help me?.

This is my code i use to check. But it doesnt work…

local function WAIT_FOR_MODEL(MAP)
	local STUFF = MAP:GetDescendants()
	local NUM = 0
	local ADDED = nil
	warn(#STUFF)
	
	ADDED = MAP.DescendantAdded:Connect(function(CHILD)
		warn(CHILD)
		if NUM >= #STUFF then
			ADDED:Disconnect()
		else
			NUM = NUM + 1
		end
		warn("CURRENT OBJECTS LOADED: " ..NUM)
	end)
	
	MAP.Parent = game.Workspace
	repeat wait() until NUM >= #STUFF
end
2 Likes

Wouldn’t checking the amount of descendants the map has before it even loads give an inaccurate value? This would most likely equal 0, which would cause the script to think the map is loaded instantly. Perhaps you could have a set value of descendants or parts of each map, and have STUFF set to that.

1 Like

I already tried that too. But it didnt work either

I also tried parenting the map before everything else. But that didnt change anything

repeat wait()
until game.Workspace.ModelNameHere
1 Like

Tried that and waitforchild too but didnt change anything :pensive:

mapChildren = game.workspace.MapNameHere:GetChildren()
repeat wait()
until #mapChildren = number of expected children of map
4 Likes

Alright i’ll try this out and see if it works

Kinda works. I’ll have to go with this

can i try this code you mark solution on localscript?