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

Preloading models is it possible ? No more LoadAsset

Asked by 9 years ago

So, hopefully the title explains it all.

I'm using the "InsertService" a lot in my game, because i'm inserting a lot of models from my profile. This makes the game lagg a bit. Here's an example:

local sword = game:GetService("InsertService"):LoadAsset(0000000000) local bow = game:GetService("InsertService"):LoadAsset(0000000001)

and so on...

i'm not only loading tools but entire models too:

local merchant = game:GetService("InsertService"):LoadAsset(0000000002)

and so on...

Then when i want to spawn one of these things i simply :clone() them and set game.Workspace as Parent. For example: mysword = sword:clone() mysword.Parent = game.Workspace

instead of using ":LoadAsset" each time i spawn something, i would like to preload everything at the beginning. This would avoid a lot of lagg.

Robloxwiki only shows how to preload sounds. Here's the example:

Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=12222058")

My question is HOW DO YOU PRELOAD MODELS ?

So far i tried these solutions and they didn't work: - local merchant = game:GetService("ContentProvider"):Preload(0000000002)) - local merchant = game:GetService("InsertService"):Preload(0000000002) - local merchant = game:GetService("ContentProvider"):Preload("http://www.roblox.com/Merchant-item?id=0000000002") - local merchant = game:GetService("ContentProvider"):Preload(0000000002)) game:GetService("InsertService"):Insert(merchant)

I tried a lot more combinations of insert and preload i even tried using only the model ID instead of writing down the entire link. So far nothing worked....

0
Instead of using a service, maybe try cloning the models from a storage instance, such as ReplicatedStorage (LocalScript) or ServerStorage (ServerScript). It doesn't use assets from the net, therefore does not cause as much latency. Redbullusa 1580 — 9y
0
i'm using server storange and it works thx :D altho i'm still experiencing some lag. it might not depend from that. do you know which one is less laggy between server storage and replicated storage ? IxIRenegadeIxI 5 — 9y
0
There's no significant difference between the two storage instances besides the fact that they're both accessed differently. As mentioned before, ServerStorage is accessed by a server script, while ReplicatedStorage is accessed by a local script. Now, the difference is the scripts itself. If this script is more applicable upon the client, you should use-a local script. But in your case, Redbullusa 1580 — 9y
0
use a server script for NPCs. Redbullusa 1580 — 9y
View all comments (4 more)
0
Thx man :) IxIRenegadeIxI 5 — 9y
0
actually im inserting big models with hills, trees and buildings. IxIRenegadeIxI 5 — 9y
0
if its a map thats all anchored then parent it to workspace then parent it back to severstorage once done RM0d 305 — 9y
0
you can directly parent it to serverstorage and later spawn it on workspace when needed :) thx anyway IxIRenegadeIxI 5 — 9y

Answer this question