If there is nothing in the table from finalList, would this code error when adding the items? (just curious.)
I also don't understand how/when it looks at the table "items", but I might just be missing it.
In either case for OP, it sounds like you want to force the player to receive a minimum of 1 item from the list, but the maximum amount of items isn't determined?
I wouldn't complete your task the way Bogart has suggested as it fits 2/3 of the criteria mentioned above.
The way bogart was completing the random chance guarenteed 1 item with random chance but would be very clunky to use if you wanted to have multiple items given out in a reward chest.
(I've used his method before, but forced the chance to be out of 100/1000/10000 so I could calculate the item chance easier.)
I'd do it like above in static's script, because it fits 2 criteria. (random chance for each item, and the maximum amount of items isn't determined.)
However, like Bogart's script it's missing that final 'something' to fit 3/3 criteria.
If the finalList returned no results, I'd simply ask the script to re-run that function again and again until it returned at least 1 result thereby achieving all 3 criteria.
^ however the above does have an increasingly smaller chance that it could run the script forever and never get a result.
You could add a failsafe that increases the chance of each item by 1, each time the script iterates through the list thereby ensuring that it doesn't run forever and still maintain the randomness of the result for as long as possible.
(so the maximum amount of iterations would be (100 - the highest chanced item), thereby forcing the script to eventually reach a gaurenteed item)
(you could also have the function run through X number of times, before skewing the chances to force the script to finish)
(maximum iterations with the above change would be (X # of times + 100 - the highest chanced item))
Although this would skew the amount of items given to players ever so slightly upwards, and for those extremely unlucky situations (script wise), would actually becoming luckier and luckier for the affected player.
^ Note that with a sufficiently large list of items (20+) in the original table this is truely only for a failsafe and the chance of it happening is so miniscule that it's almost laughable to even have the failsafe included after 10 attempts of true randomness.
umm, sorry for the block of text, I'll just stop here.