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

Why do I keep getting this error?

Asked by 9 years ago

the 'end' on line 7 is underlined in red saying "Expected '(','{' or <string> got 'end'"

function onRespawn(character) --the function where we change it to wood
    local c = character:GetChildren() --get all the objects in the character model
    for i = 1, #c do --do this to every part we find
        if (c[i].Name ~= "Torso") and (c[i].Name ~= "Head") and (c[i].Name ~= "Humanoid") and (c[i].Name ~= "HumanoidRootPartthen") then
             c[i]:Destroy 
        end
    end
end

function onChildAdded(player) --The function
    if (player.className == "Player") then --Make sure they're a player
        player.Changed:connect(--If they're changed
            function(changedthing)--do stuff before going to the real function
                if (changedthing == "Character" and player.Character ~= nil) then --make sure the char exists
                    onRespawn(player.Character)--go to the real function
                end
            end
        )
    end
end

game.Players.ChildAdded:connect(onChildAdded)

1 answer

Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
9 years ago

On line 5 c[i]:Destroy is missing an () on the end.

Edit: Also, you're checking that the name of the Part isn't equal to "HumanoidRootPartthen"- I don't think you want the "then" bit on the end.

0
Lol, didnt see that last part... Orlando777 315 — 9y
Ad

Answer this question