So basically when the player already has something in their inventory I add the value + itself then + 1 but the problem is it doesnt want to save at all
Heres a code snippet :
for i,v in ipairs(Pickupables.Weapons) do
if item and item.Name == v and (item.PrimaryPart.Position - humrp.Position).Magnitude <= 5 and item then
if Inventory:FindFirstChild(item.Name) then
for i,v in pairs(Inventory:GetChildren()) do
if v.Name == item.Name then
print(v.Name)
v.Value = v.Value + 1
end
end
elseif not Inventory:FindFirstChild(item.Name) then
local Put = Instance.new("NumberValue")
Put.Name = item.Name
Put.Value = 1
print("The player has just picked up a "..item.Name)
table.insert(InventoryTable, {Put.Name, Put.Value})
InventoryStore:Set(InventoryTable)
item:Destroy()
print("Testing")
end
end
end
end)
Im not really sure I think it’s maybe because I didnt implement it in the OnUpdate function, here i the snippet of the OnUpdate function
local function UpdateInventory(Default)
local tab = InventoryStore:GetTable(Defaults)
for i,v in pairs(tab) do
if Inventory:FindFirstChild(v) then
else
print("Adding New Item!")
local item = Instance.new("NumberValue")
item.Name = v[1]
item.Value = v[2]
item.Parent = Inventory
end
end
end
It always passes through the first check, and I dont know why because the name of the item in the table is in the inventory
Well you seem to be passing an empty variable to GetTable, as you’ve given it Defaults, yet your function only defines Default as the argument (no s).
GetTable is also for use with dictionaries, but from your Set function usable it looks like you’re storing an array instead. Try switching to Get instead of GetTable.
And I think it’s very incorrect to just claim it doesn’t save. Your evidence for it “not saving” is that it won’t load, which means there’s two places where an issue might be occurring - either at the point of saving, or the point of loading.
To assume it is only the saving that is an issue without good reason cuts your chances of finding and fixing the problem in half.