13:05:55.555 - ServerScriptService.Inventory:15: attempt to get length of upvalue 'inv' (a userdata value)
13:05:55.556 - Stack Begin
13:05:55.557 - Script 'ServerScriptService.Inventory', Line 15
13:05:55.558 - Stack End
Output ^^^^
local inv = game:GetService("DataStoreService"):GetDataStore('InventoryMetricDevGalacticzy') game.Players.PlayerAdded:Connect(function(plr) local inventory = Instance.new("Folder",plr) inventory.Name = 'Inventory' local items = inv:GetAsync(plr.UserId) or {} for i,v in pairs(items) do if game.ReplicatedStorage.ItemValues:FindFirstChild(v) ~= nil then game.ReplicatedStorage.ItemValues[v]:Clone().Parent = inventory end end inventory.ChildAdded:connect(function(c) inv[#inv+1] = c.Name -- error here inv:SetAsync(plr.UserId, inv) end) inventory.ChildRemoved:connect(function(c) local items = {} for i,v in pairs(inventory:GetChildren()) do items[i] = v.Name end inv:SetAsync(plr.UserId, items) end) end)
Script^^^
Please help it is for my game I just need a quick fix and that is all thanks :D
Line 13 of this extract:
inv[#inv+1] = c.Name
You're calling the length operator on a datastore, which you can't do
I'm guessing what you meant to do was:
items[#items+1] = c.Name inv:SetAsync(plr.UserId, items)