Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why Do I Get This Error When I Stop Testing My Game?

Cannot store Array in data store. Data stores can only accept valid UTF-8 characters.

I Don't Understand What That Means

Help!

2 answers

✓ Accepted answer

You are saving the object itself, not the value that the object holds. So, you should be using .Value after the object to get the value that the object contains.

Line 20 should look like this

DS:SetAsync("plrid_"..plr.userId, {plr.leaderstats.Steps.Value, plr.leaderstats.Races.Value})

And that will save the value of the object.

Hope this helped! If this worked, don't forget to select this as the answer!

2 comments

0

Thanks It Worked

0

No problem!

Here Is The Script:

local DS = game:GetService("DataStoreService"):GetDataStore("PermPlrDataV1.0")
game.Players.PlayerAdded:Connect(function(plr)
	wait(0)
	local plrkey = "plrid_"..plr.userId
	local savevalue = plr.leaderstats.Steps
	local savevalue2 = plr.leaderstats.Races
	
	local GetSaved = DS:GetAsync(plrkey)
	if GetSaved then
		savevalue.Value = GetSaved[1]
		savevalue2.Value = GetSaved[2]
		
	else
		local NumbersForSaving = {savevalue.Value, savevalue2.Value}
		DS:GetAsync(plrkey, NumbersForSaving)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	DS:SetAsync("plrid_"..plr.userId, {plr.leaderstats.Steps, plr.leaderstats.Races})
end)

so Like this?

local DS = game:GetService("DataStoreService"):GetDataStore("PlrDataV1.0.0")
game.Players.PlayerAdded:Connect(function(plr)
	wait()
	local plrkey = "id_"..plr.userId
	local savevalue = plr.leaderstats.Points
	local savevalue2 = plr.leaderstats.Prestige
	local savevalue3 = plr.Code

	
	local GetSaved = DS:GetAsync(plrkey)
	if GetSaved then
		savevalue.Value = GetSaved[1]
		savevalue2.Value = GetSaved[2]
		savevalue3.Value = GetSaved[3]
		
	else
		local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value}
		DS:GetAsync(plrkey, NumbersForSaving)
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Points.Value, plr.leaderstats.Prestige.Value, plr.Code.Value})
end)

3 comments

0

You have to save their values, not the object itself. On line 20, after Steps and Races put .Value to save the value of those objects.

0

you mean like this?

0

Yes, you have to save the values of the objects, not the objects itself.

This discussion is preserved as it was. New answers, comments, and votes are closed.