I keep getting the error
12:01:15.042 Workspace.SecondIsland.CoconutTree.ManageTree:33: Expected 'end' (to close 'do' at line 18), got <eof>; did you forget to close 'do' at line 28? - Studio - ManageTree:33
from this:
local tree = script.Parent
local branches = {tree.LeafBranch1, tree.LeafBranch2, tree.LeafBranch3, tree.LeafBranch4}
local toolToClone = game.ServerStorage.Coconut
local timeOfLife = 0
local timeOfMaxLife = math.random(10,20)
--Defines which branch to spawn on and clones it--
local function spawnFruit()
--Randomizes branch--
local leafToSpawn = branches[math.random(1,4)]
--Clones fruit--
local clone = toolToClone:Clone()
clone.Parent = leafToSpawn
clone.Handle.Position = leafToSpawn.Position
end
--Spawns the fruit at a random interval, and manages tree life--
while true do
wait(math.random(20,40))
timeOfLife += 1
if timeOfLife >= math.floor(timeOfMaxLife/2) then
for i = 1, #branches do
branches[i].BrickColor = BrickColor.new("Fawn brown")
end
spawnFruit()
else if timeOfLife == timeOfMaxLife then
for i = 1, #branches do
branches[i]:Destroy()
end
end
tree.Trunk.Anchored = false
end
Can anyone explaining this for me, and/or give me the fixed code? I’m puzzled on this