Just wondering, does the server actually load everything saved in studio before a client joins? Or does it load both the server and client simultaneously?
Would saying something in a local script like:
LocalScript:
1 | local event = game.ReplicatedStorage:WaitForChild( "RemoteEvent" ) |
Really be necessary? Or could I just say local event = game.ReplicatedStorage.RemoteEvent
. Do I run a risk of breaking my local script if it runs before that event loads in the server, or does something prevent that?
Custom wait for functions?
I also see some people making their own waitforchild functions in local scripts, which I also don't really understand.
Anyway...
All I really wanna know is, when is it necessary to make the local script wait for something to load, and when isn't it? Cause I don't wanna run the risk of breaking it if something doesn't exist, but I also don't want to keep typing WaitForChild
for every line of code...
Anyway, thanks for reading. Hope you can share some insight.
Yes. This is possible, but unlikely.
On particularly slow internet connections, there's not a guarantee of what order things could load. So it's possible that all of ReplicatedStorage isn't done by the time the character begins to spawn.
That is at least much less likely to be a problem for ReplicatedFirst, though I wouldn't be surprised if it could happen still, extremely rarely.
:WaitForChild
is a relatively recent addition, so older code (or code based on older code) will sometimes define it themselves.
:WaitForChild
also HAD a nasty problem: if an object is already in a model, but gets renamed to the name you're waiting for, :WaitForChild
DIDN'T see it.
There are three main reasons why you would have to wait for something: