Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to load a dictionary from a datastore?

Asked by 5 years ago
function GetSave(Key)
    local GetSave = Datastore:GetAsync(Key)
    if GetSave then
        dict = GetSave[1]
    else
        local Data = dict
        Datastore:SetAsync(Key, Data)
    end    
end

I have a thing that loads a dictionary datastore and when i go to save it, it doesnt work. But if i take this script out, it does work. So i am loading in the dictionary wrong. how do i do it right lol

0
dude use JSon greatneil80 2647 — 5y
0
You can't save dictionaries inside datastores. As greatneil80 suggested, you should use JSON. When you save data JSON encode the dictionary, that should convert the dictionary in a JSON list, a string. So the data will be able to get saved. Then when you get the data saved, get the string and JSON decode it. That should convert it in a Lua table. valchip 789 — 5y

Answer this question