local defaultstats = {
["Inventory"] = {
["Row1"]={
["Slot1"]={["Empty"]=0},["Slot2"]={["Empty"]=0},["Slot3"]={["Empty"]=0},["Slot4"]={["Empty"]=0},["Slot5"]={["Empty"]=0},["Slot6"]={["Empty"]=0},["Slot7"]={["Empty"]=0},["Slot8"]={["Empty"]=0},["Slot9"]={["Empty"]=0}
},
["Row2"]={
["Slot1"]={["Empty"]=0},["Slot2"]={["Empty"]=0},["Slot3"]={["Empty"]=0},["Slot4"]={["Empty"]=0},["Slot5"]={["Empty"]=0},["Slot6"]={["Empty"]=0},["Slot7"]={["Empty"]=0},["Slot8"]={["Empty"]=0},["Slot9"]={["Empty"]=0}
},
["Row3"]={
["Slot1"]={["Empty"]=0},["Slot2"]={["Empty"]=0},["Slot3"]={["Empty"]=0},["Slot4"]={["Empty"]=0},["Slot5"]={["Empty"]=0},["Slot6"]={["Empty"]=0},["Slot7"]={["Empty"]=0},["Slot8"]={["Empty"]=0},["Slot9"]={["Empty"]=0}
},
["Hotbar"]={
["Slot1"]={["Empty"]=0},["Slot2"]={["Empty"]=0},["Slot3"]={["Empty"]=0},["Slot4"]={["Empty"]=0},["Slot5"]={["Empty"]=0},["Slot6"]={["Empty"]=0},["Slot7"]={["Empty"]=0},["Slot8"]={["Empty"]=0},["Slot9"]={["Empty"]=0}
}
}
}
-- Above is a view of the layout of the players data entry and below is the script that SHOULD change the data.
for i,v in pairs(playerdata[player]) do
if i == "Inventory" then
for x,y in pairs(v) do -- Check rows in inventory
local rowFound = false
if rowFound then
break
end
for slot,contents in pairs(y) do -- Check slots in row
print(contents)
local slotFound = false
if slotFound then
break
end
for item,count in pairs(contents) do -- Check if slot is occupied
if table.find(contents, itemName) and count < MaxCount then -- if item is in inventory and not at limit
print("entry not nil")
count = count+1
print(slot..":")
print(contents)
rowFound = true
slotFound = true
return
elseif item == "Empty" then -- if no items of said type are in inventory
print("entry nil")
contents = {[itemName] = 1}
print(slot..":")
print(contents)
rowFound = true
slotFound = true
return
end
end
end
end
end
end
so I’ve tried reworking a couple things, and attempted to use table.Create (in a previous attempt) to still no avail. I feel the issue goes deeper than what is shown. As I’m updating the values (the updated values DO get printed to my output) but when I go to pick up another item it cycles back to saying the slot is “empty” and makes my item count 1 over and over, the print(contents) line right after the “for slot,contents in pairs(y) do” loop, prints that the contents are always empty, even though at the: print(slot…":")
print(contents)
lines it shows that the entry was updated. So apparently something else is going on here. Can anyone clarify whats going on? And potential fixes?