Is there a way to store tables

I am making a tycoon and want to use a table that stores all of the bought buttons to save their data.

Dont know how to do these

  • Adding the table data to the player
  • saving the table data
  • Getting the table data from another script
3 Likes

Hello, your best bet is to use ModuleScripts. You’ll be able to call the data inside the Module from other scripts in your environment.

like this? still not really sure how to store them to the player and save them and then load them when the player joins back


local module = require(script.Parent)

local OwnedPads = module.Pads

local function buyPad(padId)
      table.insert(OwnedPads, padId)
end

local module = {}

module.Pads = {}

return module

You need to use a datastore to store data. Roblox’s documentation has example scripts.

  1. You need to save the items as string/number values and not as instances.
  2. Have a folder in ServerStorage where you store the actual items. And when the player joins the game and has items saved , load the items from that folder. (Search for each saved item in that folder and then clone it to the players inv or something).
  3. There are quite good tutorials on saving DataStore both here & YT.
1 Like

By saving data he could also mean for that game session. For example, did player pick this thing up? Another script can also check tha value so i think modules for session store and datastores for just data saving after player left which can be loaded

simply, make a loop that checkes bought buttons, then make Table[“Button1”] = 1 – This is good practice of using table, if you wan’t it back make:

if Table["Button1"] then -- checks if table have this index


or

local button1 = Table["Button1"]

saving data is easy if you know data stores, watch this: https://www.youtube.com/watch?v=n1UpT2csAzo

1 Like