I know the title is a bit weird, but what I mean, is that I've been trying to make a item spawning script similar to Apocalypse Rising's or Deadzone's, and basically, the script uses math.random() to get the name of a random item from a table, then clone the part that corresponds with the item in the table located a few folders down from Workspace. However, I get the error "Chosen is not a valid member of Folder" where I've indicated it below. I have no idea why, and I've been trying and playing around with the script for about an hour now and just can't seem to get it. Also, I've printed the names of the items the script is getting, and they all match perfectly.
function SpawnLoot()
ClearLoot()
for i,v in pairs (CivFoodSpawners) do
local chance = math.random(1,100)
if chance >= 100 - Civ3FoodChance then -- Tier 3 Food
local Chosen = Civ3Food[math.random(1,#Civ3Food)]
local Item = game.Workspace.Loot.Food.Chosen -- Error here
local Clone = Item:Clone()
Clone.Parent = game.Workspace.ActiveLoot
Clone.Position = Vector3.new(CivFoodSpawners[i])
elseif chance >= 100 - Civ2FoodChance then -- Tier 2 Food
else
end
end
end
Thanks for any help in advance, I'd really appreciate it.

1 comment
It works! Thanks a lot!