Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I check if a folder has no children?

Asked by 6 years ago

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

Log in to vote
2
Answered by 6 years ago

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
0
Thanks! mixgingengerina10 223 — 6y
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. magicguy78942 238 — 6y
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.) lunatic5 409 — 6y
Ad

Answer this question