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?
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.
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.
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.
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!
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.
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().