Is it possible to make a database for a Roblox game?

And if it is, how can i make it?

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

*Sorry for my bad english, ik its bad

1 Like

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.

2 Likes

I forgot to say that the value i was gonna store was a table, and that didn’t work.

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.

1 Like

Yep it was and still is, I can’t store instances so I can’t do the database thing, it won’t work for my purpose

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).

Ik that but it’s too much instances to save the information for that includes scripts and models so I think it’s not viable

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

Hope this helps!

1 Like

I could use that but I need also the car’s model that contains too many instances or do the serializing thing

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.

1 Like

this devforum post may help:
How do i save an instance with Datastore Service? - Help and Feedback / Scripting Support - Developer Forum | Roblox

1 Like

I already knew about that post but I can’t use serialization because it’s too many instances and scripts to serialize.

so, is there a physical limit in place stopping you from using this method or do you just want to say no because you think its inefficient?

A physicial limit, because you can’t redo a script

so what exactly do you mean by you cant redo a script, you can put it in startergui and it will reload the script when the player gets respawned

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

1 Like

The problem is that I need to sync the car’s tune script + the a-chassis script and a bunch more with other places on the same game

didnt know that existed if im going to be honest!

1 Like

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