Log in to vote

Script keeps printing error?

Asked by 7 years ago

So whenever I run this script, an error is printed: 17:01:00.973 - attempt to index local 'wallzz' (a nil value)

This is the script:

function checkpowerup()
while wait() do
    if powerup.Value == true then
    for i = 0.4, 1.3, 0.1 do
        local wallzz = script.Parent.Parent.Torso:WaitForChild("sheeld"):FindFirstChild("Shield")
        wallzz.Mesh.Scale =, 1, 1)
        wallzz.Transparency = i

1 answer

Log in to vote
Answered by
BlueTaslem 18066 Moderation Voter Administrator Community Moderator Super Administrator
7 years ago

This means, unsurprisingly, that wallzz is nil.

You are assigning it on line 5, so that probably means you are assigning it to nil.

That is, there is no child called "Shield" inside the child named "sheeld" -- that's the case when :FindFirstChild returns nil.

First, check the spellings and capitalizations.

If there is seemingly a child, it's possible that somehow the :WaitForChild finishes only moments before "Shield" appears.

If that's the case, just use another :WaitForChild to find "Shield":

local wallzz = script.Parent.Parent.Torso:WaitForChild("sheeld"):WaitFortChild("Shield")

If you aren't convinced that "Shield" will necessarily be there, then you should check that wallz exists before doing anything to it:

local wallzz = script.Parent.Parent.Torso:WaitForChild("sheeld"):FindFirstChild("Shield") if wallzz then wallzz.Mesh.Scale =, 1, 1) wallzz.Transparency = i end

Answer this question