#Preventing the same value in a table

1 messages · Page 1 of 1 (latest)

tame rapids
#

Short example: I do math.random for a value in a table, i don't want math.random to pick the same value over and over again

I googled how i can do that but every solution seems too complex for me since i am a beginner or just aren't fit for my script. Is there any possible solutions?

cosmic geyser
#

if table[value] then return end?

#
    Super = "Super"
}

if tbl["Super"] then print(tbl["Super"]) end```
misty widgetBOT
#

studio** You are now Level 7! **studio

cosmic geyser
#

you store the value as the index of it

#
    Super = "Super"
}

tbl.Duper = "Duper"

if tbl["Super"] then print(tbl["Super"]) end

print(tbl)```
#

easiest way could be just requiring a module script where you have the table and set it to a variable

tame rapids
#

forgot that exists

cosmic geyser
#

and using table.remove to remove stuff from that

tame rapids
#

what if i want the same variables again

cosmic geyser
#

set the variable again

limpid pebble
#

and then when you pick something out of it, delete that value

#

in the clone

cosmic geyser
#

oh right you need to clone it

#

becuase it works like a refrence when you set it to a different variable