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

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

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.

1 comment

0

This should work. Are you sure the children are in the IntValue WHEN it is added?

1 answer

✓ Accepted answer

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.

2 comments

0

Useful, but he wants the children of the IntValue specifically

0

You learn something new everyday, thanks a lot!

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