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

Problem with basic script, Please Help?

Hello. I am very new to this forum and very new to scripting. I feel as though I have done everything correct, yet it doesn't work.

b3n = game.Workspace.Partz:GetChildren()

while true do
	wait(2)
	b3n:Remove()
	
end

2 comments

0

23:14:22.784 - Workspace.Partz.Script:5: attempt to call method 'Remove' (a nil value) <- Keep getting this message

0

Your problem is that you are attempting to call 'Remove' on a Table (b3n) (Table:Remove() -- Lua: What..?); This is a common mistake, so don't worry. :) The Solution is to use a 'for' loop to loop through the Table, and such. :) Also, I recommend using 'Destroy', because 'Remove' (or 'remove') has become Deprecated. :)

2 answers

First of all, "Partz" is NOT a member of workspace. But nor it Parts.

Also, try changing "b3n" to "ben" instead. This is probably not the issue, but just telling you.

This is another thing, change "Remove" to "remove" Take the capital out of it.

Here's the script it should be;

ben = game.Workspace:GetChildren()--If "Partz" is a model, then the next script below this one will help.
while true do
	wait(2)
	ben:remove()--Or you could use "Destroy" instead of "remove"

end

If "Partz" is a model, then here's the correct script;

ben = game.Workspace.Partz:GetChildren
while true do
	wait(2)
	ben:remove()--Or you could use "Destroy" instead of "remove"

end

Hope this helped, if it didn't I still love you!

2 comments

3

The problem is Remove is not a valid function for a table. Partz would have to be a member of workspace for the script to get to that point of the script. Also, a function can not be called on a table value. You would have to use a loop.

0

sorry im a beginner scripter and i try to answer the best i can. if you think your answer would be better, then post it. i dont care really.

I find that I just re-wrote it, but did it all in one line, this should be a Lot more simple for basic lua.

local b3n = game.Workspace.b3n:ClearAllChildren() --simply going to workspace, finding b3n and clearing everything inside of it also known as "children"

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