I’m looking to make a spawner system and I want to make it efficient.
I’m trying to use a module script for the item lists but I can’t figure out how to randomize it for each and every spawner considering they’ll probably be hundreds with the module script.
Doing it one by one with the module script item lists may work but a new problem arises; how can I add an item or anything with something like that.
I can’t seem to find a solution
I’d say this is a question better asked towards the new Assistant, which you can try here. I’ve asked AI numerous times your question just to see which result I was most satisfied with as a programmer and here is my best response, which comes from this conversation.
I can explain this code in my own words to help you understand what exactly here is important. The important part about this AI generated code is this segment right here:
while #itemList > 0 do
local randomIndex = math.random(1, #itemList)
table.insert(randomizedList, itemList[randomIndex])
table.remove(itemList, randomIndex)
end
This section of code locates a random index, copies the value, inserts it as a new index, and deletes the old index. This allows the table to be as random as possible by rearranging each value in a new way.
This code would work in loads of different circumstances but I would like to implement different random chances.
I will try the ai though!