2 seperate data's loaded with a button click?

How would I be able to save 2 different sets of data and load them in with a gui button click?

1 Like

Can you be more specific on what exactly you are asking about? I’m assuming you are referring to data stores when you say “save data”. For that something like this should work:

button.MouseButton1Down:connect(function() -- replace button with a pointer to your gui button
local player = nil -- replace nil with whatever code you need to use to get the player who clicked the button
local dataStore1 = game:GetService("DataStoreService"):GetDataStore("your name here")
local dataStore2 = game:GetService("DataStoreService"):GetDataStore("your other name here")
local data1 = dataStore1:GetAsync(player.UserId)
local data2 = dataStore2:GetAsync(player.UserId)
-- do what you need to do with the player data.

Ik, im just saying like, if I were to make 2 guis, could I load in a datastore with a button click, and then unload the other if they decide to go back?

1 Like

You can’t “load” and “unload” data stores, but you can remove values from a data store by setting them to nil.

Let me look into this and see if I can come up with a solutiuon.

1 Like

In the future you might want to make sure you answer the questions in About the Scripting Support category so that way people know you are talking about when you ask for help, and can help you easier.

1 Like

Ontop of what robert has said, you can use on a datastore:
:SetAsync() or :UpdateAsync() or :IncrementAsync() to change values.
However if you wanted to remove an index from a DataStore you can use: :RemoveAsync()

There’s also 2 articles on the dev dub for extra support:

  1. https://developer.roblox.com/en-us/articles/Saving-Player-Data
  2. https://developer.roblox.com/en-us/articles/Data-store

Hope you recognise DataStores can’t used on the client and how terrible this is going to be in the long run for your request budget.

You can just save several tables inside one table and then iterate through them when the button is clicked.

I forgot about that, my fault for being stupid.

No need to beat yourself up like that. You aren’t stupid for not knowing or for forgetting something. I’m not going to go on a words-of-encouragement rant but the DevForum is a (relatively) good learning resource in it’s entirety and all. Can’t be stupid for a small mistake.