Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I wait until everything's rendered/loaded?

Asked by
Zerio920 285 Moderation Voter
9 years ago

So I have the character anchored when he joins, and they're meant to stay there until everything has loaded. How do I check to make sure everything's been loaded before letting the player play?

3 answers

Log in to vote
2
Answered by
Discern 1007 Moderation Voter
9 years ago

There is a way to do this actually. A DataModel (i.e. Service) called ReplicatedFirst runs before everything is loaded.

Another DataModel called ContentProvider has the property RequestQueueSize.

When RequestQueueSize hits 0, that means everything in the game has loaded (Decals, Parts, etc.).

Since scripts are run only Locally in ReplicatedFirst, it will run only on the client, so it won't worry about any other computers running on the game.

Check this out:

LocalScript directly inside ReplicatedFirst:

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local torso = character:WaitForChild("Torso")

torso.Anchored = true --Anchoring the torso, or the entire character.
repeat wait() until game.ContentProvider.RequestQueueSize > 0 --This line will make it wait until everything is loaded.
torso.Anchored = false --Unanchoring the torso, or the entire character.
0
Genius man! Thank you :) Zerio920 285 — 9y
0
Np. :) Discern 1007 — 9y
0
Hold on, if I'm waiting until requestqueue hits 0, would I set it equal to 0 rather than checking if it's greater than 0? Zerio920 285 — 9y
0
It would be practically the same thing. Discern 1007 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Be a little more specific, tell us what you want loaded.

0
All the scripts/bricks pretty much. How long would I have to wait before everything's rendered? Zerio920 285 — 9y
0
Well go ahead and test it out. Joine the game, see how long it takes before its fully functional. Then put a wait and un-anchor the people. nightmare13542 45 — 9y
0
Everyone's computer/Internet is different and loads at different speeds. So just adding a wait won't help with a very fast or a very slow computer or Internet. Tkdriverx 514 — 9y
0
Isn't that what to loading screen is for? "Joining game" and when it shows the connectors/Bricks/etc its loading everything/ You don't have to do anything really. nightmare13542 45 — 9y
Log in to vote
0
Answered by
Maliux 0
9 years ago

Currently there isen't a way to find this. Using wait in this case will just make it after a period of time. However many computers are different from yours. I suggest just not doing this.

Answer this question