This is a continous problem I’ve been having forever and it’s starting to drive me nuts. So, whenever I play the game, I get something like this
[Infinite yield possible on ‘Workspace.Gifts.Gift7:WaitForChild(“Box”)’]
Anytime I basically use WaitForChild() on a workspace object, it 50% of the time returns this. Now, a lot of the time, I never get that, and the game runs fine, but it’s the small percentage (like 20-30% of the time) that just makes testing a pain in the …
So is there anyway for the client to wait for workspace objects to be loaded in?
Image to show that Gifts.Gift7.Box is an actual thing. So it is in the game
More testing. Set each models PrimaryPart to be Box, however, as you can see, apparently Gift4 PrimaryPart is nil, even tho you can see Gift4>PrimaryPart == Box
To add to this, as you can see in the image I attached in the post, you can Gifts1-8. It works for Gifts 1-6, then stops at 7, even tho 7’s children have the same name/properties as all the others
for i, v in pairs(workspace.Gifts:GetChildren()) do
print(v, v.Box)
end
Error
[Gift3 Box]
[Gift2 Box]
[Gift1 Box]
[09:16:47.217 - Box is not a valid member of Model]
Contrary to the name it sports, the Loaded bool/IsLoaded function actually returns a bool that determines whether the server has finished replicating instances to the client or not. It doesn’t actually do anything load wise.
That being said, there is no way to accomplish what’s being asked in the OP. I do know that this has been asked several times over to no avail.
You can take advantage of the network queue to determine this. Add a RemoteFunction somewhere and invoke it from the client, when it returns the workspace should have loaded.
SE allows you to make the game less laggy for the client. There are some caveats to it, for instance we have to use :WaitForChild() for most instances in workspace.
This is probably because the game is using a large open world or something, SE is usually recommended for large open-world maps.
Unless network streaming is enabled, LocalScripts outside of ReplicatedFirst can instantly access all instances that are parented to the DataModel prior to runtime. WaitForChild is only needed when accessing:
Instances parented during runtime
Instances outside of ReplicatedFirst from a LocalScript inside ReplicatedFirst before DataModel:IsLoaded returns true
This is what I meant by my post and I was in fact referencing that very diagram. LocalScripts don’t run until IsLoaded fires. When IsLoaded fires, the server has finished replicating instances to the client - LocalScripts start running afterward. Naturally they’d also have access to instances replicated to them from the server snapshot.
I assumed that he either had streaming enabled or parented the instances during run-time considering the fact they don’t exist in the models in his third screenshot. I’m aware that it’s not always necessary to use it, sorry for any confusion with my original post.