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?
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.
<Working with tables>:
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)