What do you want to achieve?
I want to create a autosaving system
What is the issue?
The data is not saving, and theres no error message
What solutions have you tried so far?
I did try pcalling and retrying and HttpService:JSONEncode, but none of these working
My script:
local datatosave = {
[1] = donateddata.Value;
[2] = datafold.IsNew.Value;
[3] = datafold.Weapon.Value;
[4] = datafold.Equipped.Hair.Value;
[5] = datafold.Equipped.Leg.Value;
[6] = {datafold.Equipped.LegColor.Value.r, datafold.Equipped.LegColor.Value.g, datafold.Equipped.LegColor.Value.b};
[7] = datafold.Equipped.Shirt.Value;
[8] = {datafold.Equipped.ShirtColor.Value.r, datafold.Equipped.ShirtColor.Value.g, datafold.Equipped.ShirtColor.Value.b};
[9] = {datafold.Equipped.SkinColor.Value.r, datafold.Equipped.SkinColor.Value.g, datafold.Equipped.SkinColor.Value.b};
[10] = ownedskins; --table
[11] = equippedskins; --table
[12] = ownedweapons --table
} --creating a table that includes player datas
table.foreach(datatosave[12], print) --printing out ownedweapons
local function TryUntilSuccess(waittime, callback)
local success, response
local count = 0
repeat
if count >= 1 then
warn("Retrying, count:", count, " Error:", response)
task.wait(waittime)
end
success, response = pcall(callback)
count = count + 1
until success
return success, response
end
TryUntilSuccess(7, function()
gameData:SetAsync(plrDataKey, datatosave) -- trying to save the data
end)
table.foreach(gameData:GetAsync(plrDataKey)[12], print) -- printing out saved data
it seems have no problem, i tried to run it but theres output.
--below is whats inside 12 in my data table
21:42:46.937 1 true - Server - Datas:109
21:42:46.937 3 true - Server - Datas:109
--below is 12 in data table which is what am i getting with GetAsync
21:42:47.986 1 true - Server - Datas:126
You see, SetAsync is not throwing any error but the GetAsync is not returning the result im looking for
(sorry for bad english, im not a english speaker)
Hmm. I wonder if there isn’t a problem with the callback function setup you have going. Can you set and retrieve the data without using the callback methods you have, just to verify it.
alright, i will try it. but if player gets more “weapons” then the “owned weapons” table will be modified (like this : {[1]=true, [3]=true, [6]=true, [7]=true}) then how to fill the gaps?