Datastore saving help - BoolValue issue

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

1 Like

There are no errors because you’re silencing them with pcalls. You should never pcall a function without propagating its error information. From what I’m seeing, you’re indexing “Stats”, yet “Data” was the name assigned to your “stats folder”

1 Like

Any sample code? It worked before I added the boolvalues

1 Like

I see that now, that did fix it

wow i am really dumb
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.