-
What do you want to achieve? Keep it simple and clear!
I want to save a table. The saving works… sometimes. Othertimes people randomly lose their data. I know its not a problem with servers because their int values save correctly. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I originally used this How to save Dictionary using DataStore2? - #13 by ForeverHD? to help make it, but I can’t see how to go from here.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
I’m gonna include the important parts of the code.
local dataStore2 = require(1936396537)
dataStore2.Combine("MasterKey", "StageStore", "DeathStore", "CoinsStore", "DiamondsStore", "SwordSave")
local function setUpSwords()
OwnedSwords = {
"ClassicSword"
}
return OwnedSwords
end
local function onPlayerAdded(player)
if player then
print("player.Name")
local stageStore = dataStore2("StageStore", player)
local deathStore = dataStore2("DeathStore", player)
local coinsStore = dataStore2("CoinsStore", player)
local diamondsStore = dataStore2("DiamondsStore", player)
local OwnedSwords = dataStore2("SwordSave", player):Get(setUpSwords())
if OwnedSwords and setUpSwords() then
wait(.5)
saves:FireClient(player, OwnedSwords)
for i, v in pairs(OwnedSwords)do
--sometimes errors here
print("Loaded: ".. v)
end
end
end
players.PlayerAdded:Connect(onPlayerAdded)
saves.OnServerEvent:Connect(function(player, sword)
local savedSwords = dataStore2("SwordSave", player)
table.insert(OwnedSwords, sword)
dataStore2("SwordSave", player):Set(OwnedSwords)
-- i personally think this is where the problem is, but I'm not sure
end)
No errors, when it saves everything seems to go fine. Although I did have an error I saw in the dev console for one player who joined that said something like “table expected got string instead”. This happened 4 days ago and I had been on vacation so I wasn’t able to get a screenshot of the error so sorry for that. I have not personally been able to replicate it so any help would be appreciated. Thanks!