#Can someone please what WaitForChild() means and does?
45 messages · Page 1 of 1 (latest)
it waits for a child
for example, lets say i have a part in workspace named "Part"
then, lets say i have this server script:
local part = workspace.Part
print(part.Position)
This is probably going to return an error
theres a couple specifics which i forgot 💀 but the script wont recognize a child of workspace named "part"
thats because the script will run before the part is loaded
Oooh
instead, if i did
local part = workspace:WaitForChild("Part") --looks for a child of workspace named "Part"
print(part.Position)
that would work
hierarchy
That makes so much sense now thank you bro🙏
crude drawing but a child is an instance that is parented under another instance
so in my previous example, workspace would be the parent of Part
all instances can only have 1 parent
but instances can have any number of children
so although workspace would be the only parent of Part, workspace would be a parent to multiple things (baseplate, spawn, etc)
i just took this picture from another post but here, SprintBars has 6 children
you can barely see that SprintBars is a child of another thing
thats a little more complicated
it goes into client server boundaries and replication
if your starting off, i wouldnt learn those
yet
yea
but for now, just try it out and if theres an error on that line, try using wait for child
its a bit over the top but it works
just remember that you should use wait for child in places where something loads before the script itself
np, good luck
👍
to expand on your knowledge, should learn scripting
What do you mean?
like learn how to script.
What do you think im trying to do? 😭
Im trying to understand what im actually typing
lol
Sorry
This should not have been 44 messages