Closed cntkillme closed 8 years ago
Problems like this exist throughout the engine, and there are several good arguments against fixing them in general. I'll focus on just the two examples you bring up.
char.Humanoid.MaxHealth = 200
. But since it isn't, you need to do this: char:WaitForChild("Humanoid").MaxHealth = 200
. This is uglier, sure, but it is also more performant; you only care about the Humanoid, so that's all you wait for. If CharacterAdded was a post-event, then you'd have to wait for the entire character to load, even though you only care about just one part of it.I've only really scratched the surface here, but I hope this gives you a sense of how much more complicated the issue is than it might initially seem.
Yeah those are pretty obvious points, but there's not much to load. Just the parts have to be created and parented into the character which is already what happens according to the wiki:
CharacterAdded fires when the Character is added to the Workspace. The Humanoid, Torso, and other parts of a character exist, but clothing items like hats and shirts/pants may take a few seconds to be added to the character.
so in a way what doesn't happen, should happen according to the wiki.
Character loading is not guaranteed to be asynchronous: in the case of the new R15 characters it may take several seconds. In fact, if CharacterAutoLoads is false, the character will never load but GUIs should.
The wiki should be updated to account for that here: http://wiki.roblox.com/index.php?title=API:Class/StarterGui and http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded
In the first link, it says that all the children get cloned to a Player's PlayerGui when the character spawns
(which I believe implies CharacterAdded is fired) and in the second link remove the portion that states "CharacterAdded fires when the Character is added to the Workspace" (or maybe rephrase it to state when the Character property is set).
This is a really old problem, and I'm not sure why it still exists but it does. The children in StarterGui are cloned into a player's PlayerGui when their character respawns. But at that point the
Character
property is not set by Roblox yet (which is the sole reason why local scripts have to yield before they try indexing the character). Somewhat similar is that whenCharacterAdded
is fired, all children of the Character should exist at that point and the Character is expected to be in Workspace, which is not the case.Reproduction:
Reproduction: