I have created a simple script for my game which is supposed to save the players data into the inventory datastore. The only issue is that it doesn’t even run the code that is supposed to save the players inventory data.
game.Players.PlayerRemoving:Connect(function(player)
--print(player.Name .. " is leaving")
--xpDS:SetAsync(player.UserId, player.playerStats.xp.Value)
--print("XP Saved")
--levelDS:SetAsync(player.UserId, player.playerStats.level.Value)
--print("Level saved")
--fundsDS:SetAsync(player.UserId, player.playerStats.funds.Value)
--print("Funds saved")
local playerInventory = {
["Flashlight"] = player.Inventory.Flashlight.Value,
["InfraredThermometer"] = player.Inventory.InfraredThermometer.Value,
["Glowstick"] = player.Inventory.Glowstick.Value,
["SpiritBox"] = player.Inventory.SpiritBox.Value,
["EMF"] = player.Inventory.EMF.Value,
["MotionSensor"] = player.Inventory.MotionSensor.Value,
["TracerLightWire"] = player.Inventory.TracerLightWire.Value,
["Lighter"] = player.Inventory.Lighter.Value,
}
local key = player.UserId
print(playerInventory)
print("Attempting to save inventory for " .. player.Name)
local success, response = pcall(inventoryDS.SetAsync, inventoryDS, key, playerInventory)
if success then
print("Successfully saved inventory for " .. player.Name)
else
print("Failed to save inventory for " .. player.Name .. "(" .. response .. ")")
end
end)
It never says that the data failed to save or load, I am completely lost and have absolutely no idea why this is occurring.