#Check if value exists in a table

92 messages · Page 1 of 1 (latest)

frosty olive
#

to search through a inventory folder and check if something already exists

#

i added some extra shit for people that dont know understand what im trying to do here

midnight blade
#

Whats the issue here

frosty olive
#

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

midnight blade
#

yes i got that, what is the problem tho

frosty olive
#

apparently the only thing that the output do is "Item no found bla bla bla"

#

instead of the first one

midnight blade
#

It is because you are inserting Instances to the table but searching for Strings

frosty olive
#

💀

#

maybe yes

#

how do i fix that tho

#

wait let me check what type of value the itemchosen is

midnight blade
#
table.find(existingItems, itemChosen)
#

but only change that part

frosty olive
#

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

midnight blade
#

thinking one second

frosty olive
#

ok im confirming that the "Itemchosen" is an instance

midnight blade
#

oh yeah

#

i know why

#

change the table.find back

frosty olive
midnight blade
#
table.insert(existingItems, value.Name)
#

ye

#

and change this

#

^

frosty olive
#

oh

#

i wetted myself

#

thx so much

midnight blade
#

np

frosty olive
#

@midnight blade

#

here's your bj

midnight blade
#

bye

#

whats bj lmao

frosty olive
#

blow

#

job

#

lmao

midnight blade
#

💀

#

no thanks

frosty olive
#

💀

#

alr

#

have a great day

midnight blade
#

u2

frosty olive
#

[solved]

#

hey @midnight blade

midnight blade
frosty olive
#

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
midnight blade
#

💀

#

I just realized

frosty olive
#

?

midnight blade
#

so many bad practices

#

first of all

frosty olive
#

💀

#

im all ears 💀

midnight blade
#

use

task.wait()
#

instead of wait()

#

as wait() is outdated

frosty olive
#

ok 😊

#

i kind of figured since last time i used studio was 2019

#

is there anything else i fucked up

stiff tangleBOT
#

studio** You are now Level 9! **studio

midnight blade
#

yeah many things

#

but im too tired to explain 😭

frosty olive
#

please point them out

midnight blade
#

Well uh i dont wanna tell them without explanation

#

but uh:

#

Dont use instances (IntValue, NumValue) etc to store data. Use Tables.

NEVER store important data under the client, always store and process it serverside then send the numbers to ur ui via remote event

frosty olive
#

yes

#

its just retrieving data

midnight blade
#

hm

#

anyway

#

if its ok its late here, i will explain tomorow