|
| 30 Dec 2013 12:20 AM |
if player.Character then while player.Character.Health < 1 do wait() end end while player.Character == nil do wait() end
local Contain = Instance.new("Message",player.Character)
That is the crap I have to do to get the correct Character... Is there a better way? |
|
|
| Report Abuse |
|
|
xSIXx
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 9202 |
|
|
| 30 Dec 2013 12:23 AM |
... noob
function onPlayerAdded(plr) plr.CharactedAdded:connect(function()...
or
repeat wait() until player.Character |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 12:23 AM |
Checking the Humanoid's health and not the model's health would be a good place to start...
FYI This is in a GUI |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 12:25 AM |
local char=plr.CharacterAdded:wait() -- for pros
~LuaWeaver; Programmer, gamer, developer. |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
|
| 30 Dec 2013 12:30 AM |
^ That only gets it once, and even halts the code.
Bad bad. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 12:31 AM |
"That only gets it once, and even halts the code."
Um, that's all I want and need :P |
|
|
| Report Abuse |
|
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
|
| 30 Dec 2013 01:23 AM |
| You don't understand, if it's ran too late, it will keep waiting (most likely forever, if that what you say is true, and that is all you say you need). |
|
|
| Report Abuse |
|
|
NVI
|
  |
| Joined: 11 Jan 2009 |
| Total Posts: 4744 |
|
|
| 30 Dec 2013 01:29 AM |
| Yeah, there's a chance your code could end up waiting forever if it runs after the CharacterAdded event is fired. I don't think that's what you want. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 01:30 AM |
I figured he's wrapping it in, you know, the if statement prior. Except corrected.
~LuaWeaver; Programmer, gamer, developer. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 08:34 AM |
player:WaitForChild("Character")
or
player.CharacterAdded:wait() |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 09:23 AM |
@fluff Character isnt a child of player its a property |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 30 Dec 2013 12:14 PM |
while (not player.Character) do wait() end
^thats the best you can get |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 12:36 PM |
@200AB, lets go a little rogue here
for i = 1, math.huge do wait() if player.Character then break end end |
|
|
| Report Abuse |
|
|
MettaurSp
|
  |
| Joined: 20 Mar 2010 |
| Total Posts: 3179 |
|
|
| 30 Dec 2013 01:22 PM |
| Wat. Cnt needs to post his cntified code now o3o |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 02:40 PM |
| It's funny because for whatever reason Roblox will start up the new GUI before the new Character is made. So the character is just a dead other character while the GUI is starting up which is really annoying... |
|
|
| Report Abuse |
|
|
Merely
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 17266 |
|
|
| 30 Dec 2013 02:53 PM |
local char while not player.Character do char = player.CharacterAdded:wait() end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Dec 2013 02:58 PM |
char = plr.Character or plr.CharacterAdded:wait()
|
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 03:01 PM |
Critique this:
Player.CharacterAdded:connect(function(Char) repeat wait() until Player.Character end)
That's what I had to resort to today. Unless the single wait() was enough? |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 03:02 PM |
| You guys don't seem to understand that the Character is rarely nil and sometimes, when the localscript first starts, the current player.Character is the last, now dead, character... |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 03:07 PM |
| while not Player.Character or (Player.Character:FindFirstChild("Humanoid") and Player.Character.Humanoid.Health > 0) do wait(0) end |
|
|
| Report Abuse |
|
|
Usering
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 10281 |
|
|
| 30 Dec 2013 04:23 PM |
Why not:
repeat wait() until player.Character |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 04:50 PM |
| At least most scripts won't have to worry about me. Local scripts often load up 20+ seconds after my character. Unless it's a good day, then like 5 seconds after. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 08:03 PM |
game.Workspace:WaitForChild(player.Name)
Could cause problems if something in the Workspace has the same name as the player. |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2013 09:46 PM |
@Decompiler
Like the old, dead humanoid. |
|
|
| Report Abuse |
|
|
| |
|