say we get the players character as an example and now we want the head which way should we use
which is the preferred way the player might die and or reset which could possible cause an error i am just using head to showcase this i am talking about generally or does it depend on scenario do these instances of character need to be explicitly checked for or will they always just exist making foo.foo better honestly i have a slight bad habit of using findfirstchild to get the humanoid when i am not 100% sure its essential
Char.Head
-- or --
Char:FindFirstChild("Head",recursive?) / Char:WaitForChild("Head",Yield!)
FindFirstChild() should be used when you are unsure if an object exists. WaitForChild() yields the string until the given object exists.
If it is server-side, you don’t need either of these if you are sure an item exists.
If it is client-side, you would need to use WaitForChild() so the client can have time to register the object.
doesn’t character added fire every time the player spawns back into the game after death which is good if so why would we use :waitforchild don’t all the instances inside of the players model immediately load in as they spawn. in theory you shouldn’t have to wait for anything??
There is a slight delay between the items being added - there is a tiny bit of time when Roblox loops through all the items to be added to the player. In this time, the client can look for something that doesn’t actually exist yet, hence why WaitForChild() is useful client-side.