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 that stores BoolValues?

Hey, so I'm quite new to DataStores. I'm currently making a quest thingy, where if you don't have a quest completed, you'll recieve the quest by talking to an NPC. The FirstQuest.Value will then be set to true, to indicate the quest has been taken/completed. Now, the problem arises, what if a player leaves and joins back? All their progress, lost. How do I store BoolValues e.g FirstQuest.Value?

All help is appreciated.

1 answer

✓ Accepted answer

There are some really in depth and great tutorials out there to help get you started on datastores, but here is a simple solution.

local DataStoreService = game:GetService('DataStoreService')
local Players = game:GetService('Players')

local Statistics = DataStoreService:GetDataStore('Statistics')

Players.PlayerAdded:Connect(function(Player)
	local Data = Statistics:GetAsync(Player.UserId) or {Quest1 = false, Quest2 = false}
	Quest1Bool.Value = Data.Quest1
	Quest2Bool.Value = Data.Quest2
end)

Players.PlayerRemoving:Connect(function(Player)
	Statistics:SetAsync(Player.UserId, {Quest1 = Quest1Bool.Value, Quest2 = Quest2Bool.Value})
end)

This is a very basic use of datastores, but it get's the job done.

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