Datastore doesn't save or load properly without big chunks of the data

I’m trying to use SetAsync() to save the players data to the datastore, everything works and it prints this right before saving:
image (3)

But right after joining and loading using GetAsync() it prints this, notice how the ‘Instances’ table isn’t there

image (4)

For those of you wanting the code:
Saving -PlotDataStore:SetAsync(player.UserId,newPlotData)
(newplotdata being the table shown in the first image)
Loading - local LocalPlotData = PlotDataStore:GetAsync(player.UserId) or {}
(localplotdata being the table shown in the second image without the instances array)

Let me know if you can help, Thanks! (I’m not sure any more context that I can add that would be particularly helpful, if you know something lmk!)

I think its needed to show more code cause, are u wrapping the Load and Save into a pcal?? doing retries if it fails? are u saving this when playerRemove? LocalPlotData is a variable where?

I did put it in a pcall but nothing came about, its simply just plain in the code & inserts an already-existing table made right before of it.

Well, all datastore queries should be in a pcall, and handle the result from the pcall to make sure data is loading and saving, would be better to paste the code to make modifications in it

This is basic example hope it helps you with handling the saving and loading data:

local DSS = game:GetService("DataStoreService")
local PlotDataStore = DSS:GetDataStore("PlotDataStore")

game.Players.PlayerAdded:Connect(function(player)
	local function CheckDB(playerID)
		local s, d = pcall(function()
			return PlotDataStore:GetAsync(playerID)
		end)
		if not s then
			warn("failed to check, retrying")
			wait(2)
			return CheckDB(playerID)
		end
		return s, d
	end
	
	local success, data = CheckDB(player.UserId)
	if success then
		warn("datastore check succesful")
		if data then
			warn(player, "has data, means old player")
			-- TAKE THIS DATA AND SAVE IT WHEREEVER YOU WANT TO
		else
			warn(player, "has no data, means new player")
			-- GIVE STARTING VALUES FOR THE NEW PLAYER
		end
	end	
end)


game.Players.PlayerRemoving:Connect(function(player)
	local function SaveDB(playerID, Table2Save)
		local s, er = pcall(function()
			return PlotDataStore:SetAsync(playerID, Table2Save)
		end)	
		if not s then
			warn("failed to save, retrying")
			wait(2)
			return SaveDB(playerID)
		end
		return s, er
	end
	
	local success, err = SaveDB(player.UserId, The_Table_You_Wanna_Save)
	if success then
		warn("datastore saved for:", player)
	end
end)

The problem is that you can only put strings and numbers in a datastore. The table you’re trying to put in is a table of instances, each of which is a table itself. The datastore can’t put those in.
You’ll have to find a way to convert the tables into strings and numbers before you save them.

This has since been archived so I’m not sure how you found it & that was never the issue. It was an issue on ROBLOX’s side.

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