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

How can I find a player not using localplayer?

Asked by 4 years ago

Read the title above

2 answers

Log in to vote
0
Answered by 4 years ago
1game.Players:FindFirstChild("player")
0
try this just substitue "player" with their name FizzyFlame 42 — 4y
Ad
Log in to vote
0
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.

1game:GetService("Players").PlayerAdded:Connect(function(addedPlayer)
2    print(addedPlayer.Name.." has joined the game!")
3end)

You can use Players:GetPlayerFromCharacter() as well, which gets the player from their character model in Workspace.

1Door.Touched:Connect(function(bodyPart)
2    local Character = bodyPart.Parent
3    local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
4end)

Hope this helps!

Answer this question