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

Lua C get children function?

Asked by
ziploz 7
6 years ago

I was wondering if there was a getchildren function in Lua C

getglobal game
getfield -1 Players
getfield -1 GetChildren
getfield -1 Character
getfield -1 Humanoid
pushnumber 100
setfield -2 Walkspeed

0
not too familiar with lua c but that probably equals "Players.GetChildren.Character ..." don't you have to actually call the getchildren function? cabbler 1942 — 6y

1 answer

Log in to vote
0
Answered by
ax_gold 360 Moderation Voter
6 years ago

In short: Yes, there is.

In slightly Longer: GetChildren() does exist in Lua C, and is used very often. For example, this script below will print all the Children of the Workspace. (it will not show any descendants of the children, though. Keep reading to find out how to do that.)

local children = workspace:GetChildren

for i, v in pairs(children) do
    print(v)
end

Pretty simple, right? Now, there's also another one, called GetDescendants(). This returns all descendants of the object it's called on, including things like the descendants of all descendants. It's kinda hard to explain to be honest. Here are some links if you need some more info on these:

GetChildren

GetDescendants

Ad

Answer this question