This answer’s to be used as a reference
The GetPlayerFromCharacter
function’s pretty self explanatory; it’s a function that returns a player from their character. :p This can useful for certain things, such as checking whether a character is a player’s. Here’s example with the Touched
event;
01 | Part.Touched:Connect( function (ObjThatHit) |
03 | if ObjThatHit.Parent then |
05 | local IsPlayer = game.Players:GetPlayerFromCharacter(ObjThatHit.Parent) |
07 | print (IsPlayer and 'Is a player' or 'Isn\'t a player!' ) |
Some things to note when using it;
- It’s a function of the
Players
service, so you’ll need to call it from it. Players:GetPlayerFromCharacter
- It requires the model for the player, thus the
GetPlayerFromCharacter(Model)
- If it wasn’t a player that was given to it, it’ll return nil.
Stuff touched on
GetPlayerFromCharacter
- Returns a player if what was given to it was a player’s character.
Touched
- An event that listens for when something touches the part it’s connected to.
If you have any more questions, feel free to let me know. :)
I hope this helped! :D