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

How can I access the Children of something which I'm referring to via the Child.Addded event?

Asked by 5 years ago

Alright, so I'm trying to make something happen when a Child is Added inside the Humanoid.Problem is that, that exact child will have some children of it's own, and I can't access them with the ChildAdded event.Any ideea how I might be able to do that? Here's a part of the script so you might get what I want to say if you haven't already:

humanoid.ChildAdded:Connect(function(WhatWasAdded)
    if WhatWasAdded:IsA("IntValue") then
        for i, v in pairs(WhatWasAdded:GetChildren()) do--Trying to access the children of the child added in the humanoid
            print("Got in the for")
        end
    end
end)

It doesn't print anything, and yes, it's a IntValue, and yes, I do have humanoid as a variable.The script's fine, the problem is I'm just given the Child that was Added, not it's Children aswell.

0
This should work. Are you sure the children are in the IntValue WHEN it is added? Overscores 381 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

You can use DescendantAdded event.

A child is both a child and descendant. So DescendantAdded will fire for children too.

Descendants are indirect children. Children of children.

Additionally, there is :GetDescendants() which behaves like :GetChildren() but also gets descendants.

0
Useful, but he wants the children of the IntValue specifically Overscores 381 — 5y
0
You learn something new everyday, thanks a lot! brokenrares 48 — 5y
Ad

Answer this question