- Is it guaranteed that if
player.Characterexists on the client then everything inside it also exists (meaning that characters are atomic). Or we should always use:WaitForChild()forHumanoidor any other things? - Let’s imagine that we don’t have in a game any situation where a character can die and we also have “Reset” disabled. Should we still to check for player.Character in server scripts? I have a theory that we should still check for it because client has authority of his own character so it can kill itself using exploits.
Its always good to use :WaitForChild() and :FindFirstChild() since anything could happen and possibly cause an error.
You should never use :WaitForChild() unless that instance might not exist yet. (Like when a character spawns in the Humanoid might not be loaded yet.)
When I make localscripts on the startercharacter and set a variable like “local hum = char.Humanoid” then it nearly always causes an error so I do have to use waitforchild
Yes, you do not need to use :WaitForChild() or :FindFirstChild() in scripts that are parented to the character since all of the character instances like humanoids and limbs are loaded before the scripts are. If they are parented to the players PlayerScripts or the script is created before the character then you should use :WaitForChild() and :FindFirstChild()
Then why does it always cause an error when I do that though?
It should not cause an error. Are you sending the instances name as a variable? If not, that could be the issue. It should look like this:
workspace:WaitForChild(“my_instance”)
I have “local plr = game.Players.LocalPlayer local char = plr.Character” first
Im sorry, i dont understand… Are you using :WaitForChild() to find the character?
Really appreciate it! Didn’t about it.
aaaaa
How it happens then?
function CameraService.Init(self: CameraService)
Players.LocalPlayer.CharacterAdded:Connect(function(character: Model)
camera.CameraSubject = character.Humanoid
end)
end
No, since when the Model of the “Character” is loaded, all it’s children will load after it loads so the script can load before it, so it’s better to use :WaitForChild()
Ofcourse, maybe they can reset using exploits or even if the void can be accessed.
Thank you for the answer, but maybe you know why it happens that docs state that Humanoid should exits, but in fact there is no one?
Not always. On the client, player.Character being non-nil does not guarantee that all its descendants are already present. Certain parts of the character load in stages. HumanoidDescription items, accessories, clothing, and some replicated descendants can appear a few frames later. This happens only during loading. I know this one is for sure is like that HumanoidDescription, and why many have problems working with it. A program can pull off a lot in a second so a pause here will clear that up. I like to toss in a local humanoid = ..waitforchild, just for a bit of a pause, even if I’m not going to use the local for anything.
The Roblox document seems to says the opposite, CharacterAdded event is fired after Humanoid and Default body parts have been loaded (or exist in another word).
Hmm, Interesting…
Could you print every Instance of the Character model? To see if humanoid really exists or not.
Players.LocalPlayer.CharacterAdded:Connect(function(character: Model)
print(character:GetChildren())
camera.CameraSubject = character.Humandoid
end)
am i crazy person?..
I see the problem now, It’s Humanoid not Humandoid
give me a sec, actually i did this mistake just right now, since i wasn’t able to find a fix i replaced it with :WaitForChild() and just made it back for a test
Did it work now? Or still same problem


