mu6666mu
|
  |
| Joined: 09 Apr 2012 |
| Total Posts: 952 |
|
|
| 13 Jul 2013 12:55 PM |
| How would you write a script that checks if a Child was Added Period, not to just to one item, but any item? |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Jul 2013 12:57 PM |
| Use DescendantAdded (if I'm understanding your question correctly...) |
|
|
| Report Abuse |
|
|
mu6666mu
|
  |
| Joined: 09 Apr 2012 |
| Total Posts: 952 |
|
|
| 13 Jul 2013 01:02 PM |
| ChildAdded is almost the same, but what I am trying to do is create a Plugin that removes the "print 'Hello world!'" in scripts but, I need to make it check if a script was added to anything at all. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2013 01:03 PM |
workspace.ChildAdded:connect()
Be careful with this, you'll want to put a long before it because when the game loads lots of children are added so it makes the game lag and maybe crash |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2013 01:05 PM |
Then Nate got it.
Workspace.DescendantAdded:connect(function(Child) if not Child:IsA("BaseScript") then return end --Code end) |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2013 01:06 PM |
Can't spell for my life:
Workspace.DescendantAdded:connect(function(Child) if not Child:IsA("BaseScript") then return end --Code end) |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Jul 2013 01:07 PM |
ChildAdded is completely different :P. Do you know what DescentAdded does? Pretty sure it does what you want it to do... I'd link you a page on the wiki but there are none.
workspace.DescentAdded:connect(function(descent) print(decent.. " is now a child of ".. decent.Parent) end) |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2013 01:07 PM |
@Nate ?
http://wiki.roblox.com/index.php/API:Instance/DescendantAdded |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Jul 2013 01:09 PM |
| DESCENTANDADDED... LOL dang I'm rusty, |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
| |
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Jul 2013 01:11 PM |
| Funny how I started saying in the post "DescendantAdded" then i searched the wiki for "DescentAdded" and I couldn't find it, and then I even used "DescentAdded" in my code. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2013 01:13 PM |
| Haha, I couldn't spell it too. :P |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 13 Jul 2013 01:14 PM |
| I haven't coded in a long time. |
|
|
| Report Abuse |
|
|
|
| 13 Jul 2013 01:15 PM |
| Wait a minute. . . What the heck, I did spell it right the first time. . . They're the same. o.e |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
| |
|
Tomarty
|
  |
| Joined: 08 Dec 2008 |
| Total Posts: 591 |
|
|
| 13 Jul 2013 01:51 PM |
If you wanted to check all of the scripts in game at any point in time you could use a recursive function: function Search(obj) if not obj then return end if obj:IsA("BaseScript") then -- Goodies end for _, child in pairs(obj:children() ) do Search(child) end end Search(game) |
|
|
| Report Abuse |
|
|