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

How does :GetChildren() Work?

How does :GetChildren() Work? For example if I wanted to get all the Children of Workspace and then change a property of an object if it has a certain name.

1 answer

✓ Accepted answer

The :GetChildren() Method is a method that many scriptures use. It can be used on virtually an object.

Using something like game.Players:GetChildren() will return a table of all of the hierarchical Children of game.Players. This is very useful in iterating loops, such as for loops, because you can run through a table and effect each child. In your case, you would want to do something like this:

local name = "Part"

for key, value --[[how it will run the loop]] in pairs(game.Workspace:GetChildren() --[[Our table]]) do
	if value.Name == name then --if the certain child's Name is the desired name then
		value.Name = "ChangedPart" --change the certain child's Name to "ChangedPart"
	end --end the if scope
end --end the loop scope

Check out this article on :GetChildren()

Hope this helped your understanding!

2 comments

0

Thanks!

0

No problem!

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