I’ve got a shop that autopopulates from modules. My concern is with having a visual preview of said item.
What are some ways (ideally the best for performance/memory) to get models or images of these items to populate the shop (using ViewportFrames or ImageLabels)?
Secondly, what would be the the best way to load those items into the game if a player wishes to equip that item? Would having them all already in ServerStorage be a bad idea?This game has a decent amount of teleporting between places.
I’m leaning towards uploading them as models, and using an endpoint to get the model’s thumbnail and using LoadAsset to load the model in if equipped. Does anyone have any alternatives that are about the same performance/memory (if not better)? I’m hoping to not give up much beauty for the sake of performance/memory.
The path that you take really depends on your game assets.
If the assets are static (no customization, whatever you give is what the player will get), then you can store rendered previews in a ModuleScript to show using an ImageLabel and a RemoteEvent for the client to tell the server to equip the item:
The server could clone a copy from ServerStorage: uses more memory, but the model is already present and would take little time
The server could call LoadAsset and use the returned asset, but calling the method may take some time to return the asset
PROS:
• Less memory used on the client (only need to load the image asset IDs)
• Equipping would happen within a reasonable time frame (with case 1)
• Less memory used on the server (with case 2)
CONS:
• Case 1 would use more server memory (shouldn’t be a problem as long as you’re not leaking memory)
• Case 2 would have a noticeable delay when equipping
If the assets are dynamic (customizable drinks or furniture), the only real path to take would be to store the assets in ReplicatedStorage for the client to access at any time. You would need to clone the model into a ViewportFrame for previews. For equipping, you could react instantly on the client while firing a RemoteEvent to replicate the equipping to the server and other clients as well.
PROS:
• Instant access from the client
• Animated previews
• Equipping would be instantaneous
• Very performant and reactive
CONS:
• Higher memory usage on both client and server
• Requires the usage of more expensive ViewportFrames
If you’re really looking to save memory and performance, especially when you’re expecting to house 1000+ items in your shop, then storing all assets in ServerStorage and only giving clients the preview image for each would be best. There wouldn’t be a delay compared to calling InsertService:LoadAsset(), and it’s very light on client memory.