How do I access the players character?

OK, so I’m currently writing a script where when the player clicks the button, it changes their team and their clothes. I want it to refresh/kill the player. How would I go about doing so? I just want help finding the character/humanoid. BTW, my script works like this: player clicks GUI, local script fires function, in a normal script when the event is fired, it changes the team, and changes the players avatar. I have both of those working, I just don’t know how to make it reach the character within workspace.

3 Likes

to get a player’s character you need to use Player.Character, but if the character isn’t loaded yet, you can use Player.CharacterAdded:Wait()

1 Like

I’ll try that out, thank you! Wait, so if I already got the player I can do Player.Character.Humanoid?

yes, but I think it’s better to do:


local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

because the character maybe not loaded and maybe the player has something like admin commands and puts the god command, or maybe he is an exploiter and he needs to be banned

2 Likes