And before I made the post ,yesterday I thought that my problem might be that I am setting my table nil with table . clear. So basically
How would it not set the table nil , but just clear the content of the table.
I tested this that when I used table.clear I printed my table and after clearing it in my script it came back as nil.
local function isfilled(t)
return #t > 0
end
in this little function , it needs the table to not be nil for it to return the result ( basically checks if the table has something) , but it can’t if its nil
As i said in the previous post, you should verify if Itemtype really exists in EquippedItems. For example, with debugging.
It seems it doesnt because it returns nil.
Check if the table is nil before running that function. There is no need to run that function on a table you just cleared because it checks if the size is greater than 0. Which you know it won’t be if you cleared it.
Weapons is a table, that makes Equipped items a dictionary, Weapons will have a string value with the name of the item that has been equipped and for ex, it can be “Sword”
The item being equipped is a string “sword” that is added to EquippedItems[“Weapons”], or atleast should be, actually then it would make it an array, but yeah
This function will error for anything passed that isn’t a string literal or a table literal.
local s = "Hello!"
print(#s) --6 (length of string).
local a = {"a", "b", "c"}
print(#a) --3 (length of array).
local d = {a = 1, b = 2, c = 3}
print(#d) --0 (length of dictionary).
The unary length operator when used on a string returns the length (number of characters) of that string, when used on a table it returns the length (number of items) of the array part of the table.