I created a script to make an apple appear in some tree (apple spawner), but an error occurred: saying: '' Workspace.spawn apples: 15: attempt to index local 'trunk' (a nil value) ''. help or at least explain why this error happens? script:
wait(game.Players.PlayerAdded)
applevalue = game.Workspace.arvores.valor
local applescripton = true
while applescripton == true do
wait(math.random(1,10))
local apple = game.Workspace.apple:Clone()
apple.Parent = workspace
local arvore = game.Workspace.arvores:GetChildren()
local applaspawn = arvore[math.random(1, #arvore)]
local tronco = applaspawn:FindFirstChild('tronco1')
apple.CFrame = tronco.CFrame * CFrame.new(math.random(-6,6),8,math.random(-6,6))
print(applaspawn)
end
error is in Line 12

3 comments
did not work..
it actually worked here, thanks man
lol Np :)