Answered by
4 years ago Edited 4 years ago
There are several methods.
On a server script, I use the Players.PlayerAdded event to register the player when they join the game.
1 | game:GetService( "Players" ).PlayerAdded:Connect( function (addedPlayer) |
2 | print (addedPlayer.Name.. " has joined the game!" ) |
You can use Players:GetPlayerFromCharacter() as well, which gets the player from their character model in Workspace.
1 | Door.Touched:Connect( function (bodyPart) |
2 | local Character = bodyPart.Parent |
3 | local Player = game:GetService( "Players" ):GetPlayerFromCharacter(Character) |
Hope this helps!