Hey guys! I tried to make this script read data using GetAsync, but I can't get it to work properly. Could someone please help?
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService") -- Getting data store service
Players.PlayerAdded:connect(function(player)
local TrackersData = DataStoreService:GetDataStore(player.UserId.."Trackers") -- Getting data store
local LevelTracker = Instance.new("Folder")
LevelTracker.Parent = player
LevelTracker.Name = "LevelTracker"
local Level1 = Instance.new("BoolValue")
Level1.Parent = LevelTracker
Level1.Name = "Level1"
Level1.Value = false
local Value = TrackersData:GetAsync("Level1") -- Getting value from data store "TrackersData"
if Value == nil then
TrackersData:SetAsync("Level1",false) -- if value equals nothing then it'll creates it.
else
Level1.Value = Value
end
end)

2 comments
you can only save one value when saving data to a datastore, so put all your values in a table
like?