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

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

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! ;-;

2 comments

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'.

0

Could you post the whole code please? Also, just a quick tip - use Destroy() instead of remove() :)

1 answer

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

1 comment

0

You should mark this as the answer or state why it isn't.

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