(Simple) How to make a set of random numbers that are never the same

For a map picking system, I need to pick a few random numbers within any range I need that will never be the same as the others. Like this:

Good: 1, 5 ,4

Bad: 5,1,5

1 Like

If the range is small, make a table, insert all the numbers that fall under the range into the table, and randomly choose an index, and remove that index from the table.

Thanks bro! It worked. This was the code I wrote:

local table1 = {1,2,3,4,5,6,7,8}

for i = 1, 3 do

local randomIndex = math.random(1, #table1)

print(table.remove(table1,randomIndex))

end
2 Likes