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

How would i use Data Store?

So ive made the Data Store script with SH's community people's help,But if i had a GUI,For example a currency gui and i would of liked to access the amount of coins,For example :

script.Parent.Text = RETRIVAL HERE

1 answer

✓ Accepted answer

You would simply use GetAsync to retrieve the value saved to a particular key. If you want it to update when a key's value is changed, you could also use OnUpdate (However this is throttled, so it may not always update very quickly).

OnUpdate Example:

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStoreName")
 
local connection = DataStore:OnUpdate("keyName", function(value)
	script.Parent.Text = value
end)

connection:disconnect() -- Use this when you want it to stop checking for updates

GetAsync Example:

local DataStore = game:GetService("DataStoreService"):GetDataStore("DataStoreName")
 
script.Parent.Text = DataStore:GetAsync("keyName")
-- This is good if you want to load data when a player enters

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