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

How do you store a collection of objects in a data store dictionary?

Asked by
Bisoph 5
7 years ago

I'm currently attempting to make an adventure game in Roblox; a one like Roblox Adventure 3: Rise of Nobeesi. I'm not really having problems (except trying to make a level fun) except for the DataStore. Previously, it was totally broken, because the thing didn't save/load-- but I fixed it. Unfortunately, there's still a glitch in saving. Loading works; but saving doesn't (i tested it by setting the data manually in the command bar). I found out that saving doesn't work because it can't store dictionaries inside the data store dictionary. How did Polyhex did it? Maybe he had to write like a billion items to check whether a certain Token was collected, but I don't want to do that; it's too complicated and long. How do I store a collection of objects in a DataStore dictionary, then?

For extra proof and comprehension, here is my DataStoreService module script:

001local DataModule = {}
002 
003local DataStoreService = game:GetService('DataStoreService')
004local playerData = DataStoreService:GetDataStore('PlayerData')
005local sessionData = {}
006 
007local function retry(func)
008    local s, data, tries = true, nil, 0
009    repeat
010        tries = tries + 1
011        s, msg = pcall(function()
012            data = func()
013        end)
014 
015        if not s then wait(1) end
View all 100 lines...

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
7 years ago
Edited 7 years ago

It is not the dictionary that is the problem; you just can’t save Instances inside DataStores. The best way to get around this is by saving the names of the weapons, and when loading, clone a weapon with the same name from ServerStorage and giving it to the player. For the collected stars, you could assign each star to a number, and just save a table of the star numbers that the player has collected.

Ad

Answer this question