Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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?

1 comment

0

Use player.CharacterAdded:Wait().

1 answer

✓ Accepted answer

#####[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");

2 comments

0

Thank's for helping. Now i understand how this works

0

Np bro

This discussion is preserved as it was. New answers, comments, and votes are closed.