Having Trouble with Chest ItemPool Randomizer

Hi, I made this Chest Script/fucntion and in this Script there is a part where its supposed to put randomly Generated Items inside this Table called ItemsList but, the Issue which I can’t solve is whenever it generates Items it wont put more than 1 same item inside the ItemList.

Example of the Issue would be: DropPool is DefaultChest and Amount is 100 instead of it Picking up Items randomly from DefaultChest it instead puts one of each item randomly so instead of there being 100 items its just 6 in the Chest.

local ItemPool = {
	["DefaultChest"] = {
		"Sword", "Bronze Sword", "Chestplate", "Katana", "Mace", "Helm" -- this part has been shortnened due to the amount of Items in the Script
	},
}

script.SpawnChest.OnInvoke = function(Position, DropPool, Duration,  Amount)
--- Part of this Script was Removed due to it just being about Position and DropPool (which ItemPool it will be)

local ItemList = {}
for i = 1, Amount or math.random(1, 3) do
		local Item = ItemPool[DropPool][math.random(1, #ItemPool[DropPool])]
                  --Part of this script was removed Due to it just being if the weapon is magical or no
	end
--Rest of SpawnChest script has been removed due to it just setting up chests UI
end

I think it has something to do with “Item” Variable but I’m not sure if anyone knows the Issue Please let me know and if you need more information to solve the Issue tell me and I will Provide you with the Said Information.

I have fixed the Issue, The issue wasnt with the item generator it was with the UI/Chest Open.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.