is giving me an error (table expected got nil) invalid argument #1 to ‘pairs’
the table exists .
in this situation the table was Equipped[“Weapons”]
This script under , basically is meant to be a equip script , but under circumstances works for unequipping
local function isfilled(t)
for _ in pairs(t) do return true end
return false
end
if table.find(Items,Item) then --checks if player has the item unlocked
if isfilled(EquippedItems[Itemtype] == true then
EquippedGui:FindFirstChild(itemtype):FindFirstChild(Item).Parent = InventoryGui
table.clear(EquippedItems,itemtype)
end
if itemicon:FindFirstChild("Equipped").Value == false then
itemicon:FindFirstChild("Equipped").Value = true
table.insert(EquippedItems[itemtype],Item)
itemicon.Size = UDim2.new(1,0,1,0)
itemicon.Parent = EquippedGui:FindFirstChild(itemtype)
else
itemicon.Parent = InventoryGui
itemicon:FindFirstChild("Equipped").Value = false
end
That means that EquippedItems[itemtype] must be nil, i would reccomend verifying the value of itemtype (Did you mean table.find(Items,itemtype) or isfilled(EquippedItems[Item])?)
actually the thing is that I am looking if there is anything the same type already equipped as the thing that is being equipped. (ik you deleted it but still)
is only used to identify if the player owns the item he wants to equip , since its an event on the server, the function is for checking if there is equipped a same itemtype
I was the one who recommended that function, AFAIK from his previously public code t was not an array-like table. # gets the number keys and evaluates to the greatest one, it doesn’t do anything with string keys or whatever type is used.