Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I check if a folder has no children?

I am trying to make a map loader but there is 1 problem, that the loading screen doesnt go away I tried this script but it didnt work, it also gave no errors.

localscript:

local Map = game.ReplicatedStorage.Map
local P = game.Players.LocalPlayer
while true do
print(Map:IsAncestorOf(nil))
 if Map:IsAncestorOf(nil) then
  print("Meow2")
  P.PlayerGui.Loading:Destroy()
  game.ReplicatedStorage:WaitForChild(P.Name,1000).Parent = game.Workspace
 end
wait(1)	
end


1 answer

✓ Accepted answer

It's a really easy question with an easy and simple answer

local fol = --Get your folder
if #fol:GetChildren==0 then
	--Whatever
else
	--Whatever
end

3 comments

0

Thanks!

0

No problem. This works like tables. The "#" prefix represents the amount of variables are inside a table. So when you do :GetChildren() it will gives you a table. And the "#" will count the number of variables in that table for ya.

0

This also comes in handy when checking the amount of players in a game. For example, #game:GetService("Players"):GetPlayers() will give you the number of players in a game (In this case using :GetPlayers() rather than using :GetChildren() since we are getting the players. Both give a table.)

This discussion is preserved as it was. New answers, comments, and votes are closed.