When i clone a Map from the ServerStorage to the workspace, should i sent the Parts Count with #Model:GetDescendants()
to the Client and wait until the #Model:GetDescendants()
is the same in the Client as it is in the Server or should i use RequestQueueSize
everytime?
I personally loop through all assets to load and load them one at a time.
First, we would need to get the number of assets in your model.
local desc = YourModel.GetDescandants()
local allassets = #desc
Now AllAssets is the number of parts and other effects in your model.
Next, we need to creatw a for loop, that will loop until all assets are loaded.
for i = 1, allassets do
Now, we need to load the asset.
local contentprovider = game:GetService("ContentProvider")
contentprovidor:PreloadAsset([i])
end
--Parts have all loaded
This is just a sample code. I wrote this on my mobile, so I can’t guarentee it to work. Also there might be some typos in the script. If there is any errors, tell me!
For security reasons you should not wait until the client tells you the map loaded for them if you plan to yield your code, an exploiter could just infinitely send you 0 and the server could never un-yield.
What you could do is preload the assets of all your maps at runtime with some advice given from the reply above except that :PreloadAsset() does not exist.
The code below is an example that should be put in replicatedfirst
local ContentProvider = game:GetService("ContentProvider")
local Maps = --maps folder
for _, Map in Maps:GetChildren() do
--preload meshes/textures/decals/etc. of maps
ContentProvider:PreloadAsync(Map:GetDescendants())
end
What @TenBlocke said, you can’t wait until all of the clients have loaded in on the server, since exploiters can just spoof it, you can just have it so that the server doesn’t pause but the player’s themselves can only play when they have loaded.
Hey, my Game is already secured for that, the Server just waits 30 seconds, if the Player is not loaded until these 30 seconds are finished he will be kicked from the Game.
And i cant use preloadasync because i want to wait that all the Parts inside the Model replicated to the Server and preloadasync dont works for Parts.
My Game is already secured for that, the Server just waits 30 seconds, if the Player is not loaded until these 30 seconds are finished he will be kicked from the Game. (Copied from previous comment)
Thanks but i dont think that PreloadAsync would work for Parts.
It does, I even created LoadingScreens with this myself
I know, but it will not work for Parts. The Preload will just continue and give no Errors if u preload Parts.
The Preload Async also has a function, the functions will not work with Parts and more.
But it always worked for me, and I used the same method…
Yeah because you cant know if it worked or not because it gives no Errors, it will just continue.
Okay, I didn’t know that, thanks for telling me and sorry for wasting your time
U didnt wasted, thanks for trying helping
You can try setting Camera.Focus
and Player:RequestStreamAroundAsync(x)
to the player’s/part’s position for a moment or two to load it in if you have enabled StreamingEnabled
, but you shouldn’t need to preload parts if it’s not enabled, as Roblox does it automatically.
That’s still a while for somebody to be on a loading screen.
If all Players are loaded the Game will start instantly, when one Player is still loading it will just wait 30 seconds then remove the Player.