Hello, I’m Matt, I’m trying to make a Quest system (which is working) but I’m trying to add DataStores so it saves your progress, basically there’s a boolvalue with the questName and your progress, and I’m trying to get it to save the boolvalue and the progress to load in!
Currently it’s not working, I’ve tried printing what I get from the dataStore but it’s always a blank table!
I’ve tried searching on Google and DevForum on saving Dictionaries, but nothing has worked so far!
Data Loading:
local currentQuests = player:WaitForChild("CurrentQuests")
local questsData = nil
pcall(function()
questsData = questsDataStore:GetAsync(player.UserId.."-quests")
end)
if questsData ~= nil then
for i, questName in pairs(questsData) do
if questAssets:FindFirstChild("Quests"):FindFirstChild(questName) then
local cloneQuest = questAssets:FindFirstChild("Quests"):FindFirstChild(questName)
cloneQuest:FindFirstChild("Current").Value = tonumber(i)
cloneQuest:Clone().Parent = currentQuests
quests[questName](player)
end
end
end
Data Saving:
local questsTable = {}
for _, quest in pairs(player:WaitForChild("CurrentQuests"):GetChildren()) do
if quest and questAssets:WaitForChild("Quests"):FindFirstChild(quest.Name) then
questsTable[quest.Name] = {}
table.insert(questsTable[quest.Name], quest:WaitForChild("Current").Value)
end
end
pcall(function()
questsDataStore:SetAsync(player.UserId.."-quests", questsTable)
end)
Thank you for reading, if you have anymore questions please comment them
Surely this is not an issue that someone should have to encounter. I have not seen this but I suggest using JSON Encoding. Here’s the API documentation for that, but its pretty self explanatory.
Couple of things…
If your testing this in studio then you should be aware that the game usually closes before it’s had time to run the player.removing code so it’s best to test DataStore saving in an actual published game or use BindToClose to save your data for testing.
Run a test server with one player (don’t just click the test button), and disconnect the client. The server side window should stay open, you will be able to see if there are any errors on save. Let me know how that works.
Sorry to not have a better solution yet, but diagnosis is key