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

What is the difference (":children()" and ":GetChildren()")?

Asked by
M39a9am3R 3210 Moderation Voter Community Moderator
10 years ago

Okay, I have been wondering this for a few days now, what really is the difference between these two methods? :children() and :GetChildren() I learned about :children() from Kohl's Admin Commands and when you look through his code the method is literally used on his first line of actual code.

for i, v in pairs(game:service("Workspace"):children()) do

I did some research into the methods, and found they do the same exact thing.

GetChildren's description is

Returns a read-only table of the object's children.

Children's description is

Returns a read-only table of the object's children.

Their instance is the same, and their return is the same. With that, why is :children() deprecated? I think it has absolutely no reason to be, I am wondering what exactly the difference is between the two methods?

0
On the children() wiki page it says do not use on new work. But then again I wonder why wiki staff disapprove of it. HexC3D 830 — 10y
0
I wonder why? HexC3D 830 — 10y
0
Look at the question above you, I'm guessing there is a difference. HexC3D 830 — 10y
0
Deprecation is the only difference that I know from only looking at wiki page. HexC3D 830 — 10y

3 answers

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

My hypothesis1

Simply because it's deprecated. Deprecation is a term for a property, method, class, or other item that is no longer meant to be used.

Why items are deprecated

Items are deprecated when they are no longer meant to be used for an assortment of reasons. Some examples are that the original method was a typo or does not look like other property and method names, such as Instance,className, Instance:children, or Instance:service. Other examples are when a newer alternative is available or a better way of doing something is created.

Why not to use deprecated items

Aside from the fact that ROBLOX discourages use of these items, they may be removed at any point (as you're not supposed to be using them anyways)! This can cause code to break. Another reason is that newer, better methods may exist that will be updated while older methods will not. This means that it can be harder to code with deprecated items and easier to code with newer items.

What to do if your code uses deprecated items

In most cases, when ROBLOX deprecates something, they provide an alternative. For example, the old 'children' method now has an alternative, GetChildren, which should be used instead. You can almost always simply replace the old method call with the new one and it will work. In other cases, it is harder to switch. You might have to rewrite functions or other parts of your code to get it to work.


Hope it helps!

Ad
Log in to vote
0
Answered by 9 years ago

In other words, they started with the function called "children", but then later decided that they preferred "GetChildren" (due to a change in naming convention, perhaps). Since people were already using "children" in their scripts, they decided to keep both of them to prevent scripts all over Roblox from breaking. Since they want to get rid of the "children" function eventually, they deprecated it, encouraging people to use the new name instead. Likely, a future update will remove the "children" function.

Log in to vote
0
Answered by 8 years ago

What's with all these long answers? The answer is simple, in the end they do the same, but :Children() is deprecated, which is why you use :GetChildren().

Answer this question