Hello people! I’m playing around with datastore2, trying to save a table with boolvalues’ properties when one of them gets changed. I’m quite new to data saving, so I’m kinda struggling with the solution, since data just doesn’t save at all. There are no errors in the output.
And yes, I know there are many other posts about a similar issue, but my brain just can’t seem to work anymore.
local SSS = game:GetService("ServerScriptService")
local DataStore = require(SSS.DataModule)
game.Players.PlayerAdded:Connect(function(Player)
print(Player.Name)
local ShopItems = DataStore("Items", Player)
local ItemsFolder = Player:WaitForChild("ShopItems")
local SavingItems = {}
for i, v in pairs(ItemsFolder:GetChildren()) do
if v:IsA("BoolValue") then
table.insert(SavingItems,v.Value)
print(SavingItems,v.Value)
end
end
local function updateStat(updatedValue)
SavingItems.Value = ShopItems:Get(updatedValue)
end
updateStat(false)
ShopItems:OnUpdate(updateStat())
for i,v in pairs(ItemsFolder:GetChildren()) do
v:GetPropertyChangedSignal("Value"):Connect(function()
ShopItems:Set(SavingItems.Value)
end)
end
end)
I’m grateful for any help.