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

When I try loading in data from a dictionary, it ends up responding with the data being nil?

Asked by 4 years ago

This is what I'm using to save, which appears to work pretty quickly & doesn't respond with any kind of error

local OwnData = DataStoreService:GetDataStore(Player.UserId.."-".."OCChar") or {}

    local Table =  {    
            Data1aa = CPrim.r;
            Data1ab = CPrim.g;
            Data1ac = CPrim.b;
            Data1ba = CSec.r;
            Data1bb = CSec.g;
            Data1bc = CSec.b;
            Data1ca = CTert.r;
            Data1cb = CTert.g;
            Data1cc = CTert.b;
            Data1da = CQuat.r;
            Data1db = CQuat.g;
            Data1dc = CQuat.b;
            Data1ea = CEye.r;
            Data1eb = CEye.g;
            Data1ec = CEye.b;
            Data1fa = CHair.r;
            Data1fb = CHair.g;
            Data1fc = CHair.b;
            Data1ga = CKi.r;
            Data1gb = CKi.g;
            Data1gc = CKi.b;
            Data1ha = CSkin.r;
            Data1hb = CSkin.g;
            Data1hc = CSkin.b;
            Data2a = Face;
            Data2b = Torso;
            Data2c = LArm;
            Data2d = LLeg;
            Data2e = RArm;
            Data2f = RLeg;
            Data2g = Hair;
            Data3a = Attack1;
            Data3b = Attack2;
            Data3c = Attack3;
            Data3d = Attack4;
            Data3e = Attack5;
            Data3f = Attack6;
            Data3g = Attack7;
            Data3h = Attack8;
            Data3i = Attack9;
            Data3j = Attack10;
            Data3k = Attack11;
            Data3l = Attack12;
            Data3m = Attack13;
            Data3n = Attack14;
            Data3o = Attack15;
            Data3p = Attack16;
            Data3q = Attack17;
            Data3r = Attack18;
            Data4a = Form1;
            Data4b = Form2;
            Data4c = Form3;
            Data4d = Form4;
            Data4e = Form5;
            Data4f = Form6;
            Data5a = FormH1;
            Data5b = FormH2;
            Data5c = FormH3;
            Data5d = FormH4;
            Data5e = FormH5;
            Data5f = FormH6;
        }

    local success,errormessage =  pcall(function()  
        script.Parent.Parent.Visible = false
           OwnData:SetAsync(Player.UserId.."-".."OCChar", Table)

    script.Parent.Parent.Visible = true
    local Val = Instance.new("StringValue")
    Val.Parent = script.Parent.Parent
    Val.Name = "SAVED"
    end)

    if success then
        print("Stats saved!")
    else
        print("ERROR: Stat save unsuccessful!")
        warn(errormessage) 
    end

However when it comes to loading this & trying to get the data out, it becomes nil or the value that was already preset (i.e. for color3 0,0,0):

local OwnData = DataStoreService:GetDataStore(Player.UserId.."-".."OCChar") or {}

    local success,errormessage =  pcall(function()  
        script.Parent.Parent.Visible = false
        local success, dictionary = pcall(OwnData:GetAsync(Player.UserId.."-".."OCChar"))
        local A = dictionary.Data1aa
        local A2 = dictionary.Data1ab
        local A3 = dictionary.Data1ac
        local B = dictionary.Data1ba
        local B2 = dictionary.Data1bb
        local B3 = dictionary.Data1bc
        local C = dictionary.Data1ca
        local C2 = dictionary.Data1cb
        local C3 = dictionary.Data1cc
        local D = dictionary.Data1da
        local D2 = dictionary.Data1db
        local D3 = dictionary.Data1dc
        local E = dictionary.Data1ga
        local E2 = dictionary.Data1gb
        local E3 = dictionary.Data1gc
        local G = dictionary.Data2b
        local H = dictionary.Data2c
        local I = dictionary.Data2d
        local J = dictionary.Data2e
        local K = dictionary.Data2f
        local L = dictionary.Data3a
        local L2 = dictionary.Data3b
        local L3 = dictionary.Data3c
        local L4 = dictionary.Data3d
        local L5 = dictionary.Data3e
        local L6 = dictionary.Data3f
        local L7 = dictionary.Data3g
        local L8 = dictionary.Data3h
        local L9 = dictionary.Data3i
        local L10 = dictionary.Data3j
        local L11 = dictionary.Data3k
        local L12 = dictionary.Data3l
        local L13 = dictionary.Data3m
        local L14 = dictionary.Data3n
        local L15 = dictionary.Data3o
        local L16 = dictionary.Data3p
        local L17 = dictionary.Data3q
        local L18 = dictionary.Data3r
        local M = dictionary.Data4a
        local M2 = dictionary.Data4b
        local M3 = dictionary.Data4c
        local M4 = dictionary.Data4d
        local M5 = dictionary.Data4e
        local M6 = dictionary.Data4f
        local Mb = dictionary.Data5a
        local M2b = dictionary.Data5b
        local M3b = dictionary.Data5c
        local M4b = dictionary.Data5d
        local M5b = dictionary.Data5e
        local M6b = dictionary.Data5f
        local N = dictionary.Data2a
        local O = dictionary.Data1ha
        local O2 = dictionary.Data1hb
        local O3 = dictionary.Data1hc
        local Q = dictionary.Data1fa
        local Q2 = dictionary.Data1fb
        local Q3 = dictionary.Data1fc
        local R = dictionary.Data1ea
        local R2 = dictionary.Data1eb
        local R3 = dictionary.Data1ec
        local S = dictionary.Data2g

    --[[--------------------------------------------------------------------------------------]]
    --[[--------------------------------------------------------------------------------------]]
    --[[--------------------------------------------------------------------------------------]]
    if Player:WaitForChild("StandStuff").Colours.Primary:FindFirstChild("Value") then
    Player:WaitForChild("StandStuff").Colours.Primary:FindFirstChild("Value"):Destroy()
    local Val = Instance.new("Color3Value",Player.StandStuff.Colours.Primary)
    local num1 = A
    local num2 = A2
    local num3 = A3
    Val.Value = Color3.new(num1,num2,num3)
    Val.Name = "Value"
    else
        local Val = Instance.new("Color3Value",Player.StandStuff.Colours.Primary)
    local num1 = A
    local num2 = A2
    local num3 = A3
    Val.Value = Color3.new(num1,num2,num3)
    Val.Name = "Value"
    print(Val.Value)
    end

Answer this question