I want to know how to make a variable pick a string from another variable, but not be the same as other variables picking from the main variable.
I have a main variable where all the other ones pick strings from, it's name is Characters, now I have other 6 vars. where these pick randomly a string from Characters, I have it like this:
local UC1 = Characters[math.random(1, #Characters)] local UC2 = Characters[math.random(1, #Characters)] local UC3 = Characters[math.random(1, #Characters)] local UC4 = Characters[math.random(1, #Characters)] local UC5 = Characters[math.random(1, #Characters)] local UC6 = Characters[math.random(1, #Characters)]
Afterwards it destroys the selected strings of each var. But sometimes it picks the same string as another var. so if anyone knows how to make each var. pick a string that is not the same as the others, I would appreciate it.
You could store the selected elements in an array and compare them with other randomly generated elements before inserting them into the selected elements array
local Selected = {} for i = 1, 6 do local Item = Characters[math.random(1, #Characters)] while table.find(Selected, Item) do -- while Item is inside Selected Item = Characters[math.random(1, #Characters)] end table.insert(Selected, Item) end -- do stuff with selected items