My objective is to make Project Elite’s garage and dealership as modular as possible so i can add cars easily.
Currently how Project Elite works is that when i add a car to the game, i have to manually go to every place including the main menu and add it to the garage there, but i wanted the garage from all the places to pull the car info, model, specs, etc from the cloud so i don’t have to cycle in every place so i can add the car i want. Just to make my work a little bit easier
If you want to save the data of all the cars in the cloud you can use normal Roblox datastores with a single key(for example a key named “CARS”). You can save up to 4MB of data per key in Roblox datastores, so as long you use an efficient method to represent dealership data as a dictionary it should be more than enough.
Then you only have to make a single request on game load to fetch the data(assuming no new cars are added dynamically by lets say a dev). If new cars do get added you can notify all servers using MessagingService so they update their copies without having to shut down.
Just found out how to store tables onto datastore.
So you just JSONEncode the table you want and just save it as normal.
when retrieving the data from the datastore you just JSONDecode it and it will become a table again.
I’m pretty sure you don’t have to encode and decode, it’s done automatically. The error might be caused by something else like for example trying to store an Instance to a datastore.
That’s not true. The issue with instances is that there is not a clearly defined way to save them. However if you can pinpoint down the exact information of each instance that you wish to save, you can save it in the form of a dictionary(where a key is for example a property and the value is that property value).
if your value is in a table try and convert it into a json array then convert it back to a lua table to read the contents the other place
Game1:
-- Get the datastore service and store it in a local varible.
local dataStoreService = game:getService('DataStoreService')
-- Get HttpService so we can use its Json conversion calls
local httpService = game:GetService('HttpService')
-- Create or read if already created, the "MyCars" datastore
local cars = dataStoreService:GetDataStore('MyCars')
cars:SetAsync('carName', httpService:JSONEncode(yourCarLuaTable)) -- Encode into a json array
Game2:
-- Get the datastore service and store it in a local varible.
local dataStoreService = game:getService('DataStoreService')
-- Get HttpService so we can use its Json conversion calls
local httpService = game:GetService('HttpService')
-- read "MyCars" datastore
local cars = dataStoreService:GetDataStore('MyCars')
print(httpService:JSONDecode(cars:GetAsync('carName'))) -- Decode json array into lua table and print it
ok, im going to do some researching. So the problem is that you are trying to store instances in datastore, im pritty sure storing instances in datastore is impossible unless you convert its properties into a 3d table.
You could instead save either the cars as models, and save the AssetId in a datastore. You can then insert them in game using InsertService:LoadAsset()
You could also use Packages, maybe with this method, and :LoadAsset?
You might not need to save anything in a datastore if you use packages, it seems like you might be able to put every car in a single package? Well you could do the same with models
I’m not too familiar with packages
That could be used b u t I need it to be dynamically updated, if I use this method I need to edit every car name code on every place, and I don’t want to do that because it’s too much time consuming and the fact that the game could have more than 30 places on the future doesn’t help