Boopbot
|
  |
| Joined: 11 Jul 2008 |
| Total Posts: 2284 |
|
|
| 26 Sep 2014 12:28 AM |
| I have a local script in the playergui that never works when the player first loads the game. But if I remove the script and add it back, or disable is and re-enable it, it works. If there a way so that the script will wait until the player is fully loaded before activating? |
|
|
| Report Abuse |
|
|
bob10110
|
  |
| Joined: 09 Dec 2007 |
| Total Posts: 679 |
|
|
| 26 Sep 2014 12:48 AM |
Well, you could throw a line in there like
local c = player:WaitForChild(player.Character)
and it'll yield until the player's Character has loaded in. |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2014 12:57 AM |
p = game.Players.LocalPlayer repeat wait() until p and p.Character wait() --code |
|
|
| Report Abuse |
|
|
bob10110
|
  |
| Joined: 09 Dec 2007 |
| Total Posts: 679 |
|
|
| 26 Sep 2014 01:07 AM |
Come to think of it, my solution wouldn't work anyways. I'm not sure what made me think you could do that with WaitForChild(), guess I'm still a bit rusty when it comes to scripting knowledge.
WaitForChild() would have better use looking in the Workspace, and then we get into fun little edge cases that arise if a player with the same name as one of your Models enters the place. It's probably better for some other implementation that involves waiting until the player's Character property is not a nil value, like in the previous post. |
|
|
| Report Abuse |
|
|
Boopbot
|
  |
| Joined: 11 Jul 2008 |
| Total Posts: 2284 |
|
|
| 26 Sep 2014 09:30 AM |
| Yea, I tried WaitForChild first and couldn't think of how to make it work. Thanks for the script though! |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2014 09:31 AM |
UMG ITS BOOPBOT lrn2lua bro we help u cuz we luv u |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2014 10:40 AM |
Just do
repeat wait(0) until player.Character
--ThatChristianGuy |
|
|
| Report Abuse |
|
|