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

[ SOLVED ] Why Isn't "Character" Being Recognized?

I have made a script that is supposed to delete the player's face upon joining:

game.Players.PlayerAdded:connect(function(pl)
	pl.Character:connect(function(c)
		repeat wait() until c:FindFirstChild('Head')
		c.Head.face:Destroy()
	end)
end)

However, when I go into play mode in Roblox studio, no changes are made to the player's character, and I get this error in the output:

09:30:03.798 - ServerScriptService.Script:2: attempt to index field 'Character' (a nil value)

I also tested this in an online server, and nothing is done to the player's character.

Is there a different way to get the player's character?

1 answer

✓ Accepted answer

You were so close! The event name is CharacterAdded. It seems you understand the meaning of it already.

game.Players.PlayerAdded:connect(function(pl)
    pl.CharacterAdded:connect(function(c)
        repeat wait() until c:FindFirstChild('Head') -- Not needed, since it is there once the Character is added
        c.Head.face:Destroy()
    end)
end)

1 comment

0

oh i forgot about character added lmao

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