How do I save intValues, or Values using DataStore?

Hello! I would love to learn on how to save intValues or Values using dataStore, as I am pretty new to this thing. So it would help if anyone can teach me how.

I have tried to look for tutorials but I haven’t found any, thanks!


  • Learning how to save/store intValue and Values using dataStore.


  • For games and many more!

Thats all thanks! :grinning:

To do this, you would first have to get DataStoreService by saying:
local DataStoreService = game:GetService(“DataStoreService”)

Then you would have to create a data store with DataStoreService. You can name it what ever you want in the GetDataStore() parentheses. For example:
local NewDataStore = game:GetDataStore(“NewDataStore”)

After you create the data store, you can save and get data from it. For example, if you want to save coins:
local Success,Error = pcall(function()
** NewDataStore:SetAsync(Player.UserId…“Coins”,Coins.Value)**
You will want to wrap your saving and getting data lines of code in a pcall, because a datastore might randomly show an error one time or another. The first argument is what the data is going to be stored as, and the second argument is what data is going to be stored in that spot.

To get coins, you can use GetAsync instead of SetAsync, and use a variable to get the data out of the pcall. GetAsync only needs one argument which is what the data you are looking for is stored as. For example:
local NumberOfPlayerCoins
local Success,Error = pcall(function()
** NumberOfPlayerCoins = NewDataStore:GetAsync(Player.UserId…“Coins”)**

1 Like