Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hair won't remove because y must b a nil value?

Asked by 7 years ago

So this script is for a hair removal, if you click a tool your hair will be removed but in this case it didnt work, it kept saying y must be a nil value. Here's the script.

for i=1, #y do
        if (y[i].ClassName == "Accoutrement") then
        y[i]:remove()
        end
end

Please help, :( i would very appreciate it! ;-;

0
Whatever the error was, it wasn't "y must be a nil value"; more likely, "y is a nil value" when it shouldn't be. If it was erroring on the 'for i = 1, #y do' line, then the problem is that #y doesn't exist because 'y' isn't a table. We need to see how you assign to 'y'. chess123mate 5873 — 7y
0
Could you post the whole code please? Also, just a quick tip - use Destroy() instead of remove() :) jjwood1600 215 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

See if this works.

Even if it doesn't it is the correct way to do it.

for i=1, #y do
    if y[i] then -- Makes sure that y[i] is not nil
            if (y[i].ClassName == "Accoutrement") then
                y[i]:Destroy() -- :remove() is deprecated
            end
    end
end
0
You should mark this as the answer or state why it isn't. shadownetwork 233 — 7y
Ad

Answer this question