Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

''attempt to index local 'tronco' (a nil value)'' Error?

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

1 answer

✓ Accepted answer

line (13) apple.CFrame = tronco.CFrame *

is missing a number to be multiplied by.

apple.CFrame = tronco.CFrame * 5 <---- or any number

3 comments

0

did not work..

0

it actually worked here, thanks man

0

lol Np :)

This discussion is preserved as it was. New answers, comments, and votes are closed.