Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why will these data store scripts not work?

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

2 comments

0

Did you check it out as a game outside of studio?

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

1 answer

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

2 comments

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

0

I don't know about the first script, but when you're loading the :WaitForDataReady, it should go at the very beginning.

This discussion is preserved as it was. New answers, comments, and votes are closed.