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

How do I make a datastore for boolean values?

I really want to make a game based on collecting keys, trophies, etc; I can't seem to figure out how datastores work, I've tried finding better aid via Youtube, but none of the videos expanded on how to save boolean values, I have an intermediate understanding of scripting, and I need a bit of help.

1 answer

✓ Accepted answer

To save a boolean value to a datastore (x) you would,

local Data = game:GetService("DataStoreService"):GetDataStore("x")
local Bool = true -- (or false)
local WhatPlayer = some player object

Data:SetAsync("user_"..WhatPlayer.UserId, Bool) -- data key, what to save to data key

-- to retrieve this data:

Data:GetAsync("user_"..WhatPlayer.UserId) -- returns saved data, in this case - true.

4 comments

0

This is purely to help you understand how it works - it would not be smart to set up a DataStore in this manner.

0

I understand now! Thank you so much!!!

0

Awesome! I'd appreciate it a lot if you would mark the answer as a solution since it has solved your issue. If you have any further questions about DataStores, don't hesitate to post them.

0

It wouldn't be recommended to use SetAsync for updating the value. You should be using UpdateAsync

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