0

I keep getting the error "end:4: Expected function call arguments after '('". What?

Asked by 2 years ago
while true do
for _, v in pairs(game.Workspace:GetChildren()) do
if v:WaitForChild("Part") or v.Name == "Part" then
v:Destroy
end
end



This is a workspace cleaner. Every time it returns: end:4: Expected function call arguments after '(' What does this even mean?

0
Use v:IsA(ClassName) instead of waiting for a child. Dovydas1118 1495 — 2y
0
Yeah, i'll try that, (By the way, the aitforchild is to check if it is a model with parts inside) RFL890 4 — 2y

4
Soban06 410
2 years ago
Edited 2 years ago

You are missing an end and the brackets of Destroy. Change your code to this:

while true do
for _, v in pairs(game.Workspace:GetChildren()) do
if v:WaitForChild("Part") or v.Name == "Part" then
v:Destroy() -- You also need to add brackets.
end
end
end


0
Ah. Thank you! (I never thought old me would do such an error, and use waitforchild() not IsA()) RFL890 4 — 1y