#Check if value exists in a table
92 messages · Page 1 of 1 (latest)
i added some extra shit for people that dont know understand what im trying to do here
Whats the issue here
basically
itemchosen is what u can call the return value of the outcome of a crate opening system which is fully functioning
i wanted to create a IntValue, naming it the item's name, but if it already exists in the player's inventory, add 1 to the item's value to represent the amount of that exact item you own
@midnight blade
yes i got that, what is the problem tho
apparently the only thing that the output do is "Item no found bla bla bla"
instead of the first one
It is because you are inserting Instances to the table but searching for Strings
💀
maybe yes
how do i fix that tho
wait let me check what type of value the itemchosen is
table.find(existingItems, itemChosen)
not itemChosen.Name
but only change that part
ok let me test
ill bj u if i get this working
😉
blud
💀
the shit exists but it created a new one instead of adding 1
(sinister btw)
@midnight blade
thinking one second
ok im confirming that the "Itemchosen" is an instance
back to itemchosen.name?
np
u2
yes?
now i need help
im shit with loops and pairs
its empty
wait()
local plr = game.Players.LocalPlayer
local inventoryTable = plr.Inventory:GetChildren()
for i,x in pairs(inventoryTable) do
local itemThumbnail = script.item:Clone()
itemThumbnail.Parent = script.Parent.CratesList
itemThumbnail.Text = i
itemThumbnail.quantity.Text = x
end```
i updated it a little bit but still nothing
bruh
wait()
local plr = game.Players.LocalPlayer
local inventoryTable = plr.Inventory:GetChildren()
for i,x in pairs(inventoryTable) do
local itemThumbnail = script.item:Clone()
itemThumbnail.Parent = script.Parent.CratesList
itemThumbnail.Text = x.Name
itemThumbnail.quantity.Text = x.Value
end``` still doesnt work
?
ok 😊
i kind of figured since last time i used studio was 2019
is there anything else i fucked up
** You are now Level 9! **
please point them out