Problem finding random tree (interval is empty)

Hi!
I’m writing for the second day. This time it is another topic.
The problem is that the game should pick a random tree and add it to the workspace, but I got an error that says argument 2 /interval is empty)
I’ve searched for previous posts but can’t find solution.
Script is still under development.
(I’ve used the same part of the script, lines 14 and 15, in another game where it worked)

local ServerStorage = game:GetService("ServerStorage")
local Trees = ServerStorage.Trees
local LocalForestArea = script.Parent

local function AddTree()
	print("Adding trees")
	repeat wait(5) 
	local TreeInfo = {
		TreeColor = {BrickColor.new("Slime green"), BrickColor.new("Parsley green"), BrickColor.new("Dark green")};
		TreeSize = math.random(1,5);
		TreePosition = Vector3.new(math.random(LocalForestArea.Position.X,LocalForestArea.Size.X/2),math.random(LocalForestArea.Position.Z,LocalForestArea.Size.Z/2),math.random(LocalForestArea.Position.Z,LocalForestArea.Size.Z/2))
		} 
	wait(1)
	local PossibleTrees = game.ServerStorage:WaitForChild("Trees"):GetChildren()
	local NewTree = PossibleTrees[math.random(1,#PossibleTrees)]
	NewTree.Parent = LocalForestArea.Parent
	NewTree:WaitForChild("Wood").Position = TreeInfo.TreePosition
	local RandomColor = math.random(1, #TreeInfo.TreeColor)
	NewTree:WaitForChild("Green").BrickColor = TreeInfo.TreeColor[RandomColor]
	LocalForestArea.CurrentTrees.Value = LocalForestArea.CurrentTrees.Value + 1	
	until
	LocalForestArea.CurrentTrees.Value >= LocalForestArea.MaxTrees.Value
end
--Count of trees
while wait() do
	if LocalForestArea.CurrentTrees.Value < LocalForestArea.MinTrees.Value then
		AddTree()
	end
end

Error:


Trees:
image

Thanks!

It is because you dont clone trees. After 3 iterations folder will be empty.

1 Like