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

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

Asked by
RFL890 4
4 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 — 4y
0
Yeah, i'll try that, (By the way, the aitforchild is to check if it is a model with parts inside) RFL890 4 — 4y

1 answer

Log in to vote
4
Answered by
Soban06 410 Moderation Voter
4 years ago
Edited 4 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 — 3y
Ad

Answer this question