|
| 07 Nov 2014 03:58 PM |
the function:
function WaitForChild(part,lookingfor) repeat wait() until part:FindFirstChild(lookingfor) local returned = part:FindFirstChild(lookingfor) return returned end
how to use it:
try this: first, put the function in a script. then add this local smoke = WaitForChild(game.Workspace,"Smoke") smoke:remove()
run the game and then add smoke and see as it dissapears |
|
|
| Report Abuse |
|
|
|
| 07 Nov 2014 04:15 PM |
| i saw this in scripting helpers, you copy and pasta'd |
|
|
| Report Abuse |
|
|
Alyte
|
  |
| Joined: 24 Oct 2011 |
| Total Posts: 10090 |
|
| |
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 07 Nov 2014 04:44 PM |
Here's a much cleaner version:
function Instance:WaitForChild(childName) if not self:IsDescendantOf(game) and self ~= game then error('WaitForChild called on an Instance that is not in a DataModel.', 2) end local child = self:FindFirstChild(childName) if not child then repeat child = self.ChildAdded:wait() until child.Name == childName end return child end |
|
|
| Report Abuse |
|
|
RA2lover
|
  |
| Joined: 09 Nov 2008 |
| Total Posts: 1254 |
|
|
| 07 Nov 2014 06:01 PM |
| what happened to waitforchild anyway |
|
|
| Report Abuse |
|
|
| |
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 08 Nov 2014 07:35 AM |
@Seranok;
The main reason I don't use ROBLOX's WaitForChild is because of the "Instance is not in DataModel"-error.
I have a plugin switch the source of newly-created Scripts/LocalScripts to this:
function waitForChild(instance, name, rec) if not instance:FindFirstChild(name, rec == true) then repeat wait() until instance:FindFirstChild(name, rec == true) end return instance:FindFirstChild(name, rec == true) end
function waitForProperty(instance, name) if not instance[name] then repeat wait() until instance[name] end return instance[name] end
- As |
|
|
| Report Abuse |
|
|