I’m looking to find out a way that once the player joins the game, it is determined how many seconds it takes to fully load the character and all parts in the game. Thanks.
You can use the Player.CharacterAppearanceLoaded
even to check when the character of a player has fully loaded in.
Link to docs: Player | Documentation - Roblox Creator Hub
You can use Player.CharacterAdded
to find out when the player spawns (before their character loads).
Link to docs: Player | Documentation - Roblox Creator Hub
Then you can just subtract the timestamps to find the elapsed times (e.g. using tick()
) to find the number of seconds between the two.
my bad for the misunderstanding, I was trying to determine the time until the entire game loads not just the character.
From my experience it is generally not possible in roblox. However i do have some ideas that may (or may not) work. Take the following with a grain of salt
A game is considered loaded when all instances have been streamed (or in other words - downloaded) to the client. That said, all parts, folders, values, models etc will be visible to client scripts if they are downloaded. So, you can put a LocalScript
into the ReplicatedFirst
, then every frame or so count the amount of instances, and if they match to an amount of instances visible to the Script
(server script), then you can consider the game has been loaded. Using a funciong like time() you can measure how long it took to reach this point
But I do think doind such hacky stuff is a bad idea and instead you should implement a “loading screen” for a DataStore
’s response . Depends on how you implement it tho
game.Loaded
is probably your best bet to determine the time it takes to load the game. You also have to yield for the character before-hand for it to be more accurate.
Documentation here: DataModel | Documentation - Roblox Creator Hub
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local StartTime = tick()
if not game:IsLoaded() then
game.Loaded:Wait()
end
print("Game loaded in "..tick() - StartTime.." seconds! There is around "..#game.Workspace:GetChildren().." instance(s) loaded!
NOTE: For this to work, you have to put the code above in a LocalScript, and the LocalScript has to be in ReplicatedFirst.
In my attempts to create a loading screen, game.Loaded never seems to fire after reading the previous posts more carefully, I realized this is probably a mistake on my part, especially on big games. Additionally, I recommend against waiting for a part count to match another part count, as that doesn’t account for things like the terrain, and, if you are using streamingenabled, the part count may actually never fully match.
I agree with @MrSuperKrut that loading screens should primarily exist for games when you are waiting on DataStore responses. Of course, you could try to implement some system where you try to detect if the area immediately around the player, such as a set spawn area is fully loaded.