So I have table that appears to look like this after the function is ran:
playerData["mrfrogg1"] = {
Slot1 = {Name = "Mag-G18", Type = "Mag", BulletType = "9mm", Left = "15", Max = "15"}, Slot2 = {}, Slot3 = {}, Slot4 = {}, Slot5 = {}, Slot6 = {}, Slot7 = {}, Slot8 = {}, Slot9 = {}, Slot10 = {}, Slot11 = {}, Slot12 = {}, Slot13 = {}, Slot14 = {}, Slot15 = {}, Slot16 = {},
Slot17 = {}, Slot18 = {}, Slot19 = {}, Slot20 = {}, Slot21 = {}, Slot22 = {}, Slot23 = {}, Slot24 = {}, Slot25 = {}, Slot26 = {}, Slot27 = {}, Slot28 = {}, Slot29 = {}, Slot30 = {}, Slot31 = {}, Slot32 = {},
Slot33 = {}, Slot34 = {}, Slot35 = {}, Slot36 = {}, Slot37 = {}, Slot38 = {}, Slot39 = {}, Slot40 = {}, Slot41 = {}, Slot42 = {}, Slot43 = {}, Slot44 = {}, Slot45 = {}, Slot46 = {}, Slot47 = {}, Slot48 = {},
Slot49 = {}, Slot50 = {}, Slot51 = {}, Slot52 = {}, Slot53 = {}, Slot54 = {}, Slot55 = {}, Slot56 = {}, Slot57 = {}, Slot58 = {}, Slot59 = {}, Slot60 = {}, Slot61 = {}, Slot62 = {}, Slot63 = {}, Slot64 = {},
locationX = 0,
locationY = 0,
locationZ = 0,
health = 100,
food = 100,
water = 100,
lifeTime = 0,
bleeding = false;
bagEquipped = "None",
primaryEquipped = {},
secondaryEquiped = {},
hatEquipped = {},
faceEquipped = {},
shirtEquipped = {},
pantsEquipped = {}
}
And whenever I try to do the following:
local slotName = "Slot" .. slot
local playerName = "mrfrogg1"
local selectedTablePLSWork = playerData[playerName][slotName]
print(selectedTablePLSWork["Name"])
The system would output nil.
Just to clarify, printing:
print(selectedTablePLSWork)
would output the table key, so I am assuming I am doing something wrong in regards to getting the table variable “Name”.
Edit:
Proof that the data is stored
[{“Slot27”:[],“bleeding”:false,“Slot54”:[],“Slot34”:[],“health”:100,“Slot45”:[],“Slot20”:[],“Slot49”:[],“secondaryEquiped”:[],“Slot55”:[],“Slot21”:[],“water”:100,“Slot58”:[],“Slot12”:[],“Slot53”:[],“Slot43”:[],“Slot22”:[],“Slot26”:[],“Slot17”:[],“Slot6”:[],“pantsEquipped”:[],“Slot15”:[],“Slot39”:[],“Slot14”:[],“Slot33”:[],“Slot37”:[],“Slot23”:[],“bagEquipped”:“None”,“Slot32”:[],“Slot3”:[],“Slot38”:[],“Slot31”:[],“Slot56”:[],“Slot8”:[],“Slot48”:[],“Slot60”:[],“Slot9”:[],“Slot4”:[],“Slot57”:[],“food”:100,“Slot25”:[],“Slot44”:[],“Slot11”:[],“Slot52”:[],“Slot13”:[],“Slot7”:[],“Slot5”:[],“Slot10”:[],“Slot46”:[],“Slot61”:[],“Slot59”:[],“faceEquipped”:[],“Slot16”:[],“Slot47”:[],“shirtEquipped”:[],“Slot36”:[],“Slot63”:[],“Slot18”:[],“hatEquipped”:[],“Slot1”:[{“BulletType”:“9mm”,“Left”:4,“Max”:15,“Name”:“Mag-G18”,“Type”:“Mag”}],“Slot24”:[],“Slot42”:[],“Slot2”:[],“Slot64”:[],“Slot19”:[],“locationY”:0,“locationZ”:0,“Slot51”:[],“lifeTime”:0,“Slot50”:[],“Slot28”:[],“Slot29”:[],“Slot62”:[],“primaryEquipped”:[],“Slot30”:[],“Slot35”:[],“Slot40”:[],“locationX”:0,“Slot41”:[]}]
Edit2:
Function used to assign the data:
table.insert(playerData[player.Name][slotName], {
Name = object.Name,
Type = object.Type.Value,
BulletType = object.BulletType.Value,
Left = object.Left.Value,
Max = object.Max.Value
})