cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 May 2013 02:15 PM |
repeat wait(0) until Game.Workspace:FindFirstChild("Model")
OR
while not Game.Workspace:FindFirstChild("Model") do wait(0) end |
|
|
| Report Abuse |
|
|
nairod7
|
  |
| Joined: 26 Mar 2010 |
| Total Posts: 869 |
|
|
| 27 May 2013 02:16 PM |
repeat wait(0) until Game.Workspace:FindFirstChild("Model")
-> It will wait(0) and after loop check if Game.Workspace:FindFirstChild("Model") returns true.
while not Game.Workspace:FindFirstChild("Model") do wait(0) end
-> Verify before if the model exists or not before waiting.
In that case, I would use a ChildAdded event, but it depend of your script though. |
|
|
| Report Abuse |
|
|
Cupkle
|
  |
| Joined: 18 Jun 2012 |
| Total Posts: 180 |
|
|
| 27 May 2013 02:17 PM |
| workspace:WaitForChild('Model') |
|
|
| Report Abuse |
|
|
nairod7
|
  |
| Joined: 26 Mar 2010 |
| Total Posts: 869 |
|
|
| 27 May 2013 02:19 PM |
:o
That's a function they've added recently? |
|
|
| Report Abuse |
|
|
Cupkle
|
  |
| Joined: 18 Jun 2012 |
| Total Posts: 180 |
|
|
| 27 May 2013 02:24 PM |
Yeah, pretty useful.
http://wiki.roblox.com/index.php/API:Instance/WaitForChild |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 May 2013 02:25 PM |
| What if, it's adding to lighting? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
uyjulian
|
  |
| Joined: 29 Nov 2012 |
| Total Posts: 1214 |
|
| |
|
RaidenJPN
|
  |
| Joined: 22 May 2013 |
| Total Posts: 6920 |
|
| |
|
nairod7
|
  |
| Joined: 26 Mar 2010 |
| Total Posts: 869 |
|
|
| 27 May 2013 02:56 PM |
| That's why a proper change log is needed! |
|
|
| Report Abuse |
|
|
RaidenJPN
|
  |
| Joined: 22 May 2013 |
| Total Posts: 6920 |
|
|
| 27 May 2013 03:42 PM |
@Nairod,
Let's blame all the wiki writers for not making one. |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 27 May 2013 03:46 PM |
@RaidenJPN,
http://wiki.roblox.com/index.php/WaitForChild Your not very good at this. |
|
|
| Report Abuse |
|
|
nairod7
|
  |
| Joined: 26 Mar 2010 |
| Total Posts: 869 |
|
|
| 27 May 2013 03:52 PM |
| Why the wiki writers? They don't make those new functions, they do a good work actually. I'd blame developers instead. |
|
|
| Report Abuse |
|
|
RaidenJPN
|
  |
| Joined: 22 May 2013 |
| Total Posts: 6920 |
|
|
| 27 May 2013 03:59 PM |
@Flu,
I never said that there was no wiki post on the new method.
I said that we should blame them for the lack of development log, but then Nairod suggested a better idea. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 27 May 2013 04:10 PM |
| While loop should be used when waiting for stuff to load like that. But WaitForChild is better. |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 27 May 2013 05:31 PM |
Ignoring the fact that you should use WaitForChild in this case, the best way is something like this:
while not Game.Workspace:FindFirstChild("Model") do Game.Workspace.ChildAdded:wait() end
Or if you know it's not already there, even cooler: repeat until Game.Workspace.ChildAdded:wait().Name == "Model"
Which will wait until a child actually arrives before checking again.
I use this approach a lot in gear to wait for a certain point in an animation to be reached: ... repeat until animationTrack.KeyframeReached:wait() == 'FrameImWaitingFor' ... |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
|
| 27 May 2013 05:36 PM |
| You've given us some good insights in a short time, thanks. |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 27 May 2013 05:47 PM |
| Is everyone just going to ignore that WaitForChild doesn't work? |
|
|
| Report Abuse |
|
|
|
| 27 May 2013 05:50 PM |
| It works. It _should_ and did/does. |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 27 May 2013 05:53 PM |
Well I was trying to use it like literally 5 minutes ago
Game.Players:WaitForChild("PlayerGui") print("Has gui")
Did nothing, even if I removed the PlayerGui and put a new one in
And if I tried to do something with the PlayerGui without waiting for it, it errored saying it wasn't a valid member. |
|
|
| Report Abuse |
|
|
|
| 27 May 2013 05:55 PM |
...Thats cause it'd only go once a object with the name "PlayerGui" has been added to game.Players...
game.Players.PlayerAdded:connect(function(p) p:WaitForChild("PlayerGui") print(p.Name.." has playergui") end) |
|
|
| Report Abuse |
|
|
Parthax
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 6941 |
|
|
| 27 May 2013 05:55 PM |
WaitForChild has been around for quite some time
object:WaitForChild(name) waits for a child with the name [name] inside object. |
|
|
| Report Abuse |
|
|
|
| 27 May 2013 05:56 PM |
| Now we need WaitForDescendant |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 27 May 2013 05:57 PM |
@18 That was a typo, When I tried it I used it correctly, still didn't work |
|
|
| Report Abuse |
|
|