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

[SOLVED] Easiest way to run a function when anything is inserted anywhere?

I want to make a plugin that will customise each thing I create so it will for instance, change the default text in a script, change the properties of a part and so on. The only way I can think of doing this is running through each instance when you first load up a game and connect them to a ChildAdded function and then when a child is added it runs the same function and when a child is added to that it runs the same function and so on, but this seems really inefficient but I can't think of or find a simpler way, I've searched the wiki, checked other plugins, but no luck. Any help is appreciated, thanks!

1 answer

✓ Accepted answer

There is a similar method to ChildAdded that is called DescendantAdded. This will fire every time a new descendant is added to a particular object.

For example, this program will print the string representation of every instance added to the game:

game.DescendantAdded:connect(function(child)
	print(child)
end)

1 comment

0

Oh, I just thought that was another fancy way of doing ChildAdded. Thanks!

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