How do I access the player through the character?
1 | local player = hit.Parent:GetPlayerFromCharacter() |
I've made a teleport script that teleports players into the fighting arena for my game. Just recently I decided to look back into the script to add in the "inCombat" mode once they've used the teleporter, but in order to turn on the value that's in the player's stats folder I have to get to the player.
The teleporter is a simple touch event. I thought if I were to get the player who is touching the part, and reference their character by doing hit.Parent
then adding :GetPlayerFromCharacter()
it would lead me to be able to enter the stats folder in the player.
I'm assuming I'm using :GetPlayerFromCharacter() wrong, so is there a way I can access the player through a .touched event at all?
16:11:08.543 - GetPlayerFromCharacter is not a valid member of Model
16:11:08.544 - Stack Begin
16:11:08.544 - Script 'Workspace.DoorTeleporter.Teleport', Line 20
16:11:08.544 - Stack End
is the error that I'm receiving.
I tried checking if maybe I'm not getting the actual character model in the workspace by using print(). I put in print(hit.Parent) and it gave me the character name, so I'm completely lost on why it's not working.
Does :GetPlayerFromCharacter() have a different function that I'm not understanding? And if it does, what's the proper way to access the player through a .touched event? Is that possible?