I confused about the solution you posted though. It doesn’t seem to be solving the problem you posted.
Instead it’s swapping elements in the table, and at the start of the loop it’s likely that it will just be swapping one entry with the same entry.
For example, in your loop when i == 1
j = math.random(i) will also be 1, because the random values are between 1 and 1.
Then you swap entry 1 with entry 1, which is obviously not going to do anything.
t[i], t[j] = t[j], t[i] --AKA t[1], t[1] = t[1], t[1]
Even when i == 2, you have a 50% chance of nothing happening, as the only possibilities are:
t[2], t[1] = t[1], t[2] --swap entries t[2], t[2] = t[2], t[2] --nothing happens
and in all cases you have not overcome your problem with repetition.
Now that I’ve edited my post (and actually tested it out), I know that my method definitely works.