Were Arrays/tables disabled?

image, Recently started getting this notification. Is this normal?

My script goes like this:

game.Players.PlayerAdded:Connect(function(plr)

local purchases = Instance.new("IntValue",plr)
purchases.Name = "Purchases"
local TotalPrice = Instance.new("IntValue",purchases)
TotalPrice.Name = "Total"

local DataOfUser = ds:GetAsync(plr.UserId)

if DataOfUser ~= nil then
	purchases.Value = datastore[1]
	TotalPrice.Value = datastore[2]
else
	purchases.Value = 0
	TotalPrice.Value = 0
end

end)

game.Players.PlayerRemoving:Connect(function(plr)
local datasave = {}
table.insert(datasave, plr:WaitForChild(“Purchases”).Value)
table.insert(datasave, plr:WaitForChild(“Purchases”):WaitForChild(“Total”).Value)

local success, response = pcall(function()
	ds:SetAsync(plr.UserId, datasave)
end)

if success then
	print("Successfully saved data of " .. plr.Name)
else
	warn("oops! Was unable to successfully save data of " .. plr.Name .. " | RESPONSE: " .. response)
end

end)

2 Likes

According to this article:
https://developer.roblox.com/en-us/articles/Datastore-Errors

The error is circumstancial but it is not certain why. The data should have saved correctly, if you read the example from the other page regarding saving the data.

2 Likes

I use the exact same system on my other game, but it doesn’t give me the error?
image
(don’t mind the errors, that is incomplete scripting that isn’t a part of the datastore script)

As I have previously stated, it is a circumstancial matter, meaning that error is random. Does the error re-occur consistently for every test or is there something else around that system?

Been testing it a few times now, and it keeps working on the other game, but doesnt work on the game im working on right now. No errors happend & data is always found on the first game, but the second one doesn’t seem to do the same. But, I think it’ll stop eventually since it’s random, pretty annoying tbh though. Does this mean that this error might happend but it will still save data?

Actually, I have mistaken again and apparently you cannot save arrays. Dictionaries are allowed in the contrary.

These two lines would explain that. See if your other system does that.

This is so confusing, i did exactly that too. It saves the datasave table.

Other system:


This system:

That’s interesting, I can’t deduce why there is an inconsistency between these two. Are you absolutely certain that the other system is working or if that was a fluke?

I’m completely certain, the script even inform me (previous image) that the data has been found and it being loaded in, followed by an example of the ban reason (if there is one).

An alternative solution should be utilizing a session cache. The cache should create an entry using the player’s user ID, which then contains a dictionary containing those values as written in the system above. The cache would be reflected by the value object’s value changes after it was loaded. Once the player leaves, the values from the cache is saved.

Do not use table.insert(). Assign it like: table[key] = x

You may have inadvertently changed the data type that the DataStore expects along with the UserId key.

That is one possibility that somehow the table he saved was a mixed type. However, I cannot identify any operations in the other system that actually converted the table into a mixed type. It seems to be an array as well.

OKAY AFTER TRYING FOR A BIT, I figured it out.
Your method did work but then i noticed why i did it wrong, I used an ordered datastore instead of just a datastore :woman_facepalming:
Sorry for the troubles

2 Likes