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

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
6 years ago

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)

0
oh i forgot about character added lmao Warfaresh0t 414 — 6y
Ad

Answer this question