when trying to find the object in the table it just doesnt work i dont know why
print(obj)
print(data.locker[obj])
for i, obj in pairs(data.locker) do
those 2 lines of code are in this function it finds it before
when trying to find the object in the table it just doesnt work i dont know why
print(obj)
print(data.locker[obj])
for i, obj in pairs(data.locker) do
those 2 lines of code are in this function it finds it before
You should be doing data.locker[i]
because i is the key of the object in the table.
Take a look at this page for more information:
Can you send the full code with the table?
Can you send your entire script?
I’m not sure why are you both replying to me. I’m not the OP.
for i, v in pairs(data.locker) do
print(i) -- will print the name of the item in the locker
print(v) -- will print the value of the item in the locker
end
There’s really no point in referencing the locker to print the item’s value. Instead, use ‘v’ (value) because you’re already iterating through the locker.
data.locker[i]
is the exact same as
v
Essentially, your code is referencing ‘data.locker’ to print something when you don’t need to do that. In the code I wrote above, ‘v’ will give you the value you’re looking for. Also, when you’re trying to find an item in a table, use the index/key instead of the value.
data.locker[i] -- do this
data.locker[v] -- not this
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.