I wrote a script for the table and for the data to be stored there in the module, but it does not work. Help me solve the problem. I watched a lot of video tutorials and didn’t find a solution.
local DataStore = game:GetService("DataStoreService"):GetDataStore("QuestsMBA")
local QuestsName = {
"ThugQuest",
"JotaroQuest",
"DioQuest",
}
local SaveableSettings = {
"IsActive",
"Completed",
"Step",
"Progress",
}
game:GetService("Players").PlayerAdded:Connect(function(player)
local Quest = script:FindFirstChild("QuestsModule"):Clone()
Quest.Parent = player
-------------------
for _,item in pairs(require(Quest).Info) do
for i,v in pairs(SaveableSettings) do
if table.find(item,v) then
for _,v in pairs(DataStore:GetAsync(player.UserId)) do
item = v
print(item.." and "..v)
end
end
end
end
-------------------
game:GetService("Players").PlayerRemoving:Connect(function(player)
local Quest = require(player:FindFirstChild("QuestsModule"))
----------------------------------------------
local Data = {}
for _,item in pairs(Quest.Info) do
for i,v in pairs(SaveableSettings) do
if table.find(item,v) then
table.insert(Data,item)
end
end
end
DataStore:SetAsync(player.UserId,Data)
----------------------------------------------
end)