Basically, I am currently making a custom backpack and I got stuck on one bit.
local Items = game.Workspace.randommodel:GetChildren()
local Slots = {
[1] = randomobject,
[2] = randomobject,
[3] = randomobject,
[4] = randomobject,
[5] = randomobject,
[6] = randomobject,
[7] = randomobject,
[8] = randomobject,
[9] = randomobject,
[0] = randomobject
}
for i,v in pairs(Items) do
if v.Name ~= Slots[i].Name then -- is this how you get the name of the object?
local e2 = v:Clone()
e2.Parent = script.Parent.ValueHolder
Slots[i] = e2
end
end
(read the comment in the script to understand the problem)
Thank you for reading and possibly answering
All you’re doing there is comparing the same thing, checking if they’re not equal to each other. v.Name is the same as Slots[i].Name in this scenario.
EDIT: But yes, I believe doing either v.Name or Slots[i].Name will get the name(s) of the object(s) in the table. Also, if you want to search the table in index-order, then you’ll want to use in ipairs.
Yeah alright thank you, that’s what I thought.
(The code’s purpose is to check if there isn’t an item with the same name in the backpack already, and if there isn’t, add the new item to the backpack)