generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: My Version Of Old WaitForChild

Previous Thread :: Next Thread 
regancool1234 is not online. regancool1234
Joined: 29 Dec 2013
Total Posts: 192
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
builderman0621 is not online. builderman0621
Joined: 13 Jul 2010
Total Posts: 1612
07 Nov 2014 04:15 PM
i saw this in scripting helpers, you copy and pasta'd
Report Abuse
Alyte is not online. Alyte
Joined: 24 Oct 2011
Total Posts: 10090
07 Nov 2014 04:21 PM
Dude!
Report Abuse
Seranok is not online. 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 is not online. RA2lover
Joined: 09 Nov 2008
Total Posts: 1254
07 Nov 2014 06:01 PM
what happened to waitforchild anyway
Report Abuse
regancool1234 is not online. regancool1234
Joined: 29 Dec 2013
Total Posts: 192
07 Nov 2014 10:17 PM
I DIDNT COPY AND PASTE
Report Abuse
As8D is online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image