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

Why do I keep getting this error?

the 'end' on line 7 is underlined in red saying "Expected '(','{' or 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

✓ Accepted answer

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.

1 comment

0

Lol, didnt see that last part...

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