I have a boolvalue in a folder called “Relic1” but yet it is not saving.
I will send the code below, it is pretty simple to read
No errors output in the console
local dss = game:GetService("DataStoreService")
local levelDS = dss:GetDataStore("P1@y3rD@t@")
function saveData(player)
pcall(function()
local relic1 = player.Stats.RelicsData.Relic1.Value
levelDS:SetAsync(player.UserId .. "P1@y3rD@t@", {relic1})
end)
end
game.Players.PlayerAdded:Connect(function(player)
local statsFolder = Instance.new("Folder", player)
statsFolder.Name = "Data"
local relicsFolder = Instance.new("Folder", statsFolder)
relicsFolder.Name = "RelicsData"
local relic1data = Instance.new("BoolValue", relicsFolder)
relic1data.Name = "Relic1"
pcall(function()
local data = levelDS:GetAsync(player.UserId .. "P1@y3rD@t@")
if data then
relic1data.Value = data[1]
end
end)
end)
game.Players.PlayerRemoving:Connect(saveData)
game:BindToClose(function()
for i, player in pairs(game.Players:GetPlayers()) do
saveData(player)
end
end)
Don’t see any memory leak issues or anything