Hi, I recently switched from using an external database to using DataStore2 but have been having issues with saving a table. So from the picture, as you see I am trying to update the table but in the actual database, nothing is changing. If you know a solution to this, let me know.
local dsWins = DataStore2("Wins", player)
local dsDeaths = DataStore2("Deaths", player)
local dsDiamonds = DataStore2("Diamonds", player)
local dsItem = DataStore2("Item", player)
local dsSecretPass = DataStore2("SecretPass", player)
local dsUserTags = DataStore2("UserTags", player)
local getWins = dsWins:Get(0)
local getDeaths = dsDeaths:Get(0)
local getDiamonds = dsDiamonds:Get(0)
local getItem = dsItem:Get("None")
local getSecretPass = dsSecretPass:GetTable({S1 = { XP = 0 }})
local getUserTags = dsUserTags:GetTable({Equipped = "None", Owned = {}})
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Parent = leaderstats
Wins.Value = getWins
local Deaths = Instance.new("IntValue")
Deaths.Name = "Deaths"
Deaths.Parent = leaderstats
Deaths.Value = getDeaths
local extraleaderstats = Instance.new("Folder")
extraleaderstats.Name = "extraleaderstats"
extraleaderstats.Parent = player
local Diamonds = Instance.new("IntValue")
Diamonds.Name = "Diamonds"
Diamonds.Parent = extraleaderstats
Diamonds.Value = getDiamonds
local SecretPass = Instance.new("Folder")
SecretPass.Name = "SecretPass"
SecretPass.Parent = player
local XP = Instance.new("IntValue")
XP.Name = "XP"
XP.Parent = SecretPass
XP.Value = getSecretPass.S1.XP
local UserTags = Instance.new("Folder")
UserTags.Name = "UserTags"
UserTags.Parent = player
local Equipped = Instance.new("StringValue")
Equipped.Name = "Equipped"
Equipped.Parent = UserTags
Equipped.Value = getUserTags.Equipped
local Owned = Instance.new("Folder")
Owned.Name = "Owned"
Owned.Parent = UserTags
local jsonString = getUserTags.Owned
local tableJSON = HttpService:JSONDecode(jsonString)
if type(tableJSON) == "table" then
for k, v in pairs(tableJSON) do
local Data = Instance.new("StringValue")
Data.Name = k
Data.Value = v
Data.Parent = Owned
end
end
game.ReplicatedStorage.TagsData:FireClient(player, "refresh")
local tagLevels = {
[5] = "ShadowMaster",
[10] = "SupremeOverlord",
[15] = "EmberHighlord",
[20] = "MysticEnforcer",
[25] = "SpectralOverlord",
[30] = "MythicalLegend"
}
local SecretPassLvl = math.floor(XP.Value / 25)
local function setPlayerTag(tag)
dsUserTags:Set({Owned = {[tag] = "Owned"}})
local tagdata = Instance.new("StringValue")
tagdata.Name = tag
tagdata.Value = "Owned"
tagdata.Parent = Owned
game.ReplicatedStorage.TagsData:FireClient(player, "refresh")
end
for level, tag in pairs(tagLevels) do
if SecretPassLvl >= level then
if not Owned:FindFirstChild(tag) then
setPlayerTag(tag)
end
end
end