So I'm trying to store some values, they're boolean values. In a nutshell: they are there to determine whether the player owns a certain weapon or not.
of course I want to save this data, so to do that I came up with the following script:
local plyrdatalist = game.ServerScriptService.PlayerData:GetChildren() --This is a folder in ServerScriptService that contains a copy of all the boolean values that should be in the player. CashKey = "PlayerCash" game.Players.PlayerAdded:connect(function(player) if player:WaitForDataReady() then -- create leaderboard local ls = Instance.new("IntValue") ls.Name = "leaderstats" ls.Parent = player --create the Cash stat local Cash = Instance.new("IntValue") Cash.Name = "Cash" Cash.Parent = ls Cash.Value = player:LoadNumber(CashKey) local KillCount = Instance.new("IntValue") KillCount.Name = 'Kills' KillCount.Value = 0 KillCount.Parent = player.leaderstats local PlayerData = Instance.new("Folder") --This is the folder that should contain the boolean values PlayerData.Name = "PlayerData" PlayerData.Parent = player.leaderstats for i = 1, #plyrdatalist do --This is where I try to make those values local WeaponBool = Instance.new("BoolValue") WeaponBool.Name = plyrdatalist[i].Name WeaponBool.Value = player:LoadBoolean(plyrdatalist[i].Name) WeaponBool.Parent = player.leaderstats.PlayerData end end end) game.Players.PlayerRemoving:connect(function(player) if player:FindFirstChild("leaderstats") then player:SaveNumber(CashKey, player.leaderstats.Cash.Value) for i = 1, #plyrdatalist do --This is where I try to save the values player:SaveBoolean(plyrdatalist[i].Name, player.leaderstats.PlayerData[plyrdatalist[i].Name].Value) end end end)
Right now, it does save cash, but when none of the boolean values get copied into the folder. There is just an empty folder in leaderstats. I did test this in-game, not in Studio.
All help is welcome. C: