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

What other way could I connect to a Player?

Asked by
uhTeddy 101
6 years ago

I usually have used game.Players.LocalPlayer while I'm trying to connect to the player from workspace. While this for some reason only works in - studio. If you could I would really like some other way to connect to the player.

0
The LocalPlayer is only accessible in `LocalScripts`. Are you trying to use it in a server script? ImageLabel 1541 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

game.Players.LocalPlayer only works in a local script. Anyway there is another way to get the player. You could use the function :GetPlayerFromCharacter() In the () you put the character of the player. For example :

local tool = script.Parent --tool
local char = tool.Parent --the player's character
local player = game.Players:GetPlayerFromCharacter(char) -- this get the player that has this tool

Remember you can use :GetPlayerFromCharacter() for anything, it doesn't have to be a tool.

Ad

Answer this question