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

Why will these data store scripts not work?

Asked by 8 years ago

According to the ROBLOX Wiki: Data Stores can save tables.

I tried that, once saving and loading. The first code should save the table, and the second code should load the table.

local tabledatastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Knives")
    tabledatastore:SetAsync("Table",{   player.Cardboard.Value, --LINE 7
                                        player["Cup of Tea"].Value,
                                        player["Diamond Camo"].Value,
                                        player["Murderer Knife"].Value,
                                        player["Neon Green"].Value,
                                        player.Paper.Value,
                                        player["Purple Galaxy"].Value,
                                        player["Rainbow Zebra"].Value,
                                        player.Waffle.Value,
                                        player["Woodland Camo"]})

Output error: 15:46:58.298 - Cannot store Array in DataStore 15:46:58.299 - Script 'Workspace.SaveLeaderboard', Line 7 15:46:58.299 - Stack End

LOADING

DSS = game:GetService("DataStoreService"):GetDataStore(player.Name.."Knives")
    knifetable = DSS:GetAsync("Table")
        if knifetable[1] then --LINE 77
            player.Cardboard.Value = true
            Num.Value = Num.Value+1
        else
            print("Cardboard false")
        end

Output error: 15:46:50.117 - Workspace.SaveLeaderboard:77: attempt to index global 'knifetable' (a nil value) 15:46:50.118 - Stack Begin 15:46:50.119 - Script 'Workspace.SaveLeaderboard', Line 77 15:46:50.120 - Stack End

0
Did you check it out as a game outside of studio? KingLoneCat 2642 — 8y
0
Hi King, these errors have also been reported by some players while I was with them. This means that they occur on the servers and in Studio fahmisack123 385 — 8y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
8 years ago

You're not calling player:WaitForDataReady(), resulting in the data being loaded before it is available, therefore resulting in a nil value.

0
Could you please show me where in the script I should insert this? And how about the error for the first bit of code fahmisack123 385 — 8y
0
I don't know about the first script, but when you're loading the :WaitForDataReady, it should go at the very beginning. P100D 590 — 8y
Ad

Answer this question