Can someone please help, the error is on line 36 where it say: local data = {plr.leaderstats.Shirts, plr.leaderstats.Money.Value} Can someone please help me fix this error
local DS = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr
local shirts = Instance.new("IntValue")
shirts.Name = "Shirts"
shirts.Value = 0
shirts.Parent = stats
local cash = Instance.new("IntValue")
cash.Name = "Money"
cash.Value = 0
cash.Parent = stats
local plrkey = "id_"..plr.userId
local save1 = plr.leaderstats.Shirts
local save2 = plr.leaderstats.Money
local GetSaved
local success, failed = pcall(function()
GetSaved = DS:GetAsync(plr.UserId)
end)
if success then
save1.Value = GetSaved[1]
save2.Value = GetSaved[2]
print(plr.Name.." Successfully recived the data!")
else
print("There was an error while getting data!")
warn(failed)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local data = {plr.leaderstats.Shirts, plr.leaderstats.Money.Value}
local success, fail = pcall(function()
DS:SetAsync(plr.UserId, data)
end)
if success then
print(plr.Name.."'s Data was successfully saved!")
else
print("There was an error while saving data!")
warn(fail)
end
end)
The output is saying:
There was an error while saving data!
19:03:54.803 - 104: Cannot store Array in data store. Data stores can only accept valid UTF-8 characters.

1 comment
You need a dictionary