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

How can i print how long it took for everything in the game to load for a player?

Asked by
oSyM8V3N 429 Moderation Voter
6 years ago

I was thinking of doing something like this :

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character


while true do
    repeat wait() until game.ContentProvider.RequestQueueSize > 0 --This line will make it wait until everything is loaded.
end
print("it took".. game.ContentProvider.RequestQueueSize.. "to load"
--repeat wait() until game.ContentProvider.RequestQueueSize > 0 --This line will make it wait until everything is loaded.

But i realized that it was all non sense and i don't actually know how, even after i tried,

Anyone mind helping me out?

0
Use player.CharacterAdded:Wait(). hiimgoodpack 2009 — 6y

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
6 years ago
Edited 6 years ago
[Important fixes]

First of all, you need to get rid of your while loop. It's redundant.

Secondly, compare the RequestQueueSize with the proper constructor: ==

-------------

[Tick]

Now, for this you should take advantage of the tick function.

Here is an example of it's usage:

local before = tick(); --Before the action
print("Hello world");
local after = tick(); --After the action
print(after-before) --Difference between the two

-------------

[Application]

To apply this to your case, define a tick function proceeding & preceding the repeat loop :)

local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local before = tick(); --Preceding tick function

repeat wait() until game.ContentProvider.RequestQueueSize == 0

local after = tick(); --Proceeding tick function
print("it took "..after-before.." to load");
0
Thank's for helping. Now i understand how this works oSyM8V3N 429 — 6y
0
Np bro Goulstem 8144 — 6y
Ad

Answer this question