Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to link together multiple DataStore entries?

I'm making a space game where I need to persist items using a DataStore. I can store the item's data in a table, however I need to reference it in multiple locations:

  • The player's stats database
  • The database for the solar system it is in

I need to access a list of every item belonging to a player, as well as a list of every item in a specific solar system. How should I format my data to be able to get this functionality? I can't just duplicate the item into the two DataStores because I need to move it around and update its information.

If I was storing the information in a MySQL database then I would just use foreign keys, but there's no ROBLOX equivalent.

I originally thought to store each object using its own specific ID as the DataStore key, but then there's no easy way (that I can think of) to assign a completely unique ID number to the object when it is created. This would also mean that loading a solar system with a lot of objects would take ages due to the request limits.

3 comments

0

If I understood correctly you want to be able to access the datastore from any script?

0

With the script : print("hax on!")

0

@RequiredModule, I want to be able to link together the data, so I can have a database of structures which can be referenced from the player's inventory as well as solar systems.

1 answer

Use HttpService:GenerateGUID() to generate a unique identifier for the data, then simply use that as the key for the datastore.

This discussion is preserved as it was. New answers, comments, and votes are closed.