It doesn’t print it anymore, idk why, I didn’t change anything
Does the data work properly now?
Nope, it doesn’t, I can try a few more things but idk what to do
Oh, this may be the issue but I am not sure. You’re defining the quest completion with a table that only has one value. It would be easier (and may fix your code) to define the quest as only the number.
i.e
["Open Shop"] = 0
vs.
["Open Shop"] = {0}
If you are currently attempting to do something along the lines of:
LoadedValue = Data["Open shop"]
calling LoadedValue will return the entire table. You would need to use LoadedValue[1] to access only the number value
How would I be able to do that?
That it looks like this
local questsTable = {
["Open Shop"] = 0
}
In your saving code, change
questsTable[quest.Name] = {}
to
questsTable[quest.Name] = quest:WaitForChild("Current").Value
(and remove the table.insert)
Yes it does work, but now I just need the loading system to work!
What is your issue there?
Also, is the first issue resolved?
I found another problem, when I do the quest and it turns 1 when I leave and rejoin it does go to 1 but if I leave and rejoin again it goes back to 0
Some of these issues may be related to testing in studio. Try testing in-game a few times and see if you have the same issues.
Change
for i, questName in pairs(questsData) do
to
for questName, i in pairs(questsData) do
in your loading script
I already did that, made a difference though
It’s just table: 0xc7bf074d136a3934
Also with the module script function it just says attempt to index nil with value
Oh the issue is I didn’t do the module
I’m about to be off for the night, but I will say debug printing can be your best friend.
Add prints everywhere something important happens to make sure the code is actually running consistently & check that the data you expect is what is going through. Use the information you gain about what is and isn’t working to try to figure out why from problem A to problem Z.
Ok, will do, good night, cya sometime
Does anyone know any other solutions?
Hello my fellow amazing awesome spectacular Roblox Developers out there, I figured out what to do, so if you’re stuck on this type of question too here is what I did!
Saving:
local questsTable = {}
for _, quest in pairs(player:FindFirstChild("CurrentQuests"):GetChildren()) do
if quest then
questsTable[quest.Name] = {
["Current"] = quest:FindFirstChild("Current").Value;
["Reward"] = quest:FindFirstChild("Reward").Value;
["Goal"] = quest:FindFirstChild("Goal").Value;
}
end
end
pcall(function()
questsDataStore:SetAsync(player.UserId, questsTable)
end)
Loading:
local questsData = nil
pcall(function()
questsData = questsDataStore:GetAsync(player.UserId)
end)
if questsData ~= nil then
for questName, questValues in pairs(questsData) do
if not player:FindFirstChild("CurrentQuests"):FindFirstChild(questName) and #player:FindFirstChild("CurrentQuests"):GetChildren() < 3 then
local questValue = Instance.new("BoolValue")
questValue.Name = questName
questValue.Value = true
questValue.Parent = player:FindFirstChild("CurrentQuests")
local rewardValue = Instance.new("NumberValue")
rewardValue.Name = "Reward"
rewardValue.Value = tonumber(questValues.Reward)
rewardValue.Parent = questValue
local currentValue = Instance.new("NumberValue")
currentValue.Name = "Current"
currentValue.Value = tonumber(questValues.Current)
currentValue.Parent = questValue
local goalValue = Instance.new("NumberValue")
goalValue.Name = "Goal"
goalValue.Value = tonumber(questValues.Goal)
goalValue.Parent = questValue
game:GetService("ReplicatedStorage"):FindFirstChild("QuestsAssets"):FindFirstChild("Remotes"):FindFirstChild("SendQuest"):FireClient(player, questName, tonumber(questValues.Reward), tonumber(questValues.Goal))
game:GetService("ReplicatedStorage"):FindFirstChild("QuestsAssets"):FindFirstChild("Remotes"):FindFirstChild("UpdateQuest"):FireClient(player, questName, questValues.Current, questValues.Goal)
if currentValue.Value >= goalValue.Value then
game:GetService("ReplicatedStorage"):FindFirstChild("QuestsAssets"):FindFirstChild("Remotes"):FindFirstChild("UpdateQuest"):FireClient(player, questName, questValues.Current, questValues.Goal)
game:GetService("ReplicatedStorage"):FindFirstChild("QuestsAssets"):FindFirstChild("Remotes"):FindFirstChild("ShowClaim"):FireClient(player, questName)
game:GetService("ReplicatedStorage"):FindFirstChild("QuestsAssets"):FindFirstChild("Remotes"):FindFirstChild("SendCompleteNotification"):FireClient(player, questName)
questModule[questName](player)
require(replicatedStorage:FindFirstChild("ElevatorFunctions")):MuteSFX(replicatedStorage:FindFirstChild("SFX"):FindFirstChild("Notification"))
end
end
end
end