Jump to content

Easier explanation for Get Children


Recommended Posts

Hi, I'm just a developer who's pretty new to scripting and I've been searching for a way to use GetChildren. A lot of tutorials I've seen are really helpful but they only explain what it is, and I still don't know how to correctly put/use it in a script. If someone could please give me pointers in the right direction that would be great. Thanks

Share this post


Link to post
Share on other sites

An example for this would be getting children through "for i,v" if you know what that is, heres and example:
 

Spoiler

for i,v in pairs(game.Workspace:GetChildren()) do
      v.Parent = game.ReplicatedStorage
end

Of course you wouldn't do that but its just an example,
GetChildren simply gets all that you can see under the path you reference, for example

If I do game.Workspace:GetChildren() on a entirely new map, that would return a table of
local table = {
Terrain,
Baseplate,
Camera
}
By putting that in a "for i,v" you can sort of expand the table, be noted though, a "for i,v" goes through the entire table repeating the action.

Edited by Karasu
  • Upvote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.