So I want to learn about the children functions. But I can't find a good tutorial explaining it. Does anyone have any good site or video to learn it?
Any good tutorial on the function children()?
1 answer
Hello there, well as @ForeverBrown said Roblox's GetChildren source is really useful, but like you said you want a "good tutorial" well i can't really give you that but, however, i can give you an example of an GetChildren action here:
Counting how many parts are in the workspace:
for n,p in pairs(workspace:GetChildren()) do
print("There's:",n,"Parts in the workspace")
end
As well as removing everything from a: Model,Part,Folder,Etc:
for _,g in pairs(workspace:GetChildren()) do
g:Destroy()
end
But there's an easier way to do that unless you want to remove not everything but only parts, or values or something like that then you'd have to do an if statement like this:
for _,p in pairs(game.Players:GetPlayers()) do
if p:IsA("Player") then
print"ok he a player"
end
end
^^^ Well ofcourse it's a player but you get it.
Also there's functions like > :ClearAllChildren which is really useful.
:
local admins = {"zetruis","testsubject2"}
for _,adminlist in pairs(admins) do
if (adminlist=game.Players.LocalPlayer.Name) then
print"You're an admin!"
else
print"Sorry you're not an admin!
end
end
Yes i know i used a localscript as an example but here's an serverscript example same as that ^^
local admins = {"zetruis","testsubject2"}
game.Players.PlayerAdded:Connect(function(p)
for _,adminlist in pairs(admins) do
if (adminlist=p.Name) then
print"You're an admin!"
else
print"Sorry you're not an admin!
end
end
end)
3 comments
I like your script examples. But you should probably explain what the letters mean. Like for q,r in pairs(table) do something
Alright i'll edit it, look at it again.
Well ofcourse i messed up on the point that using names insted of userid's but it's just an example.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Use GetChildren() ... Children() is depreciated https://developer.roblox.com/en-us/api-reference/function/Instance/GetChildren
If you know how to use tables and iterating through them, then GetChildren should be easy for ya :)