I'm making a random chest spawning spot but there's a problem. Here's the code:
local treasure = script.Parent.Treasure.Value
local common = game.Lighting.Chests.CommonChest1
local uncommon = game.Lighting.Chests.UncommonChest1
local rare = game.Lighting.Chests.RareChest1
local epic = game.Lighting.Chests.EpicChest1
local legendary = game.Lighting.Chests.LegendaryChest1
local chances = {common,common,common,common,common,common,common,common,common,common,uncommon,uncommon,uncommon,uncommon,uncommon,rare,rare,rare,epic,epic,legendary}
while wait(10) do
if treasure == false then
treasure = true
chest = chances[math.random(1,#chances)]:Clone()
chest.Parent = script.Parent
end
end
When the player takes the chest the treasure value is set back to false so that's not a problem, but still it doesn't spawn another chest. Can anybody help please?

2 comments
You're not setting the treasure value back to false after it spawns.
The treasure value does go back after the chest is taken but even after that it doesn't spawn