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

How can I get to someone in Player through a GUI?

Asked by 10 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

I'm making some game, and when someone clicks a GUI, I don't want them to die, so I want to load their character, but I only know how to get to them in Workspace.

0
Are you referring to the :LoadPlayer() method? Aethex 256 — 10y

3 answers

Log in to vote
1
Answered by
Andalf 100
10 years ago

From the gui you can use a localscript with the following line to get the player

local player = game.Players.LocalPlayer

You can also just use

local player = game.Players:FindFirstChild('Name of Player') if you want to get someone whose name you have.

Ad
Log in to vote
1
Answered by 10 years ago

If you're using a LocalScript, then game.Players.LocalPlayer will reference the player.

However, if you aren't, there's a simple solution.

m = game.Workspace.Player:GetPlayerFromCharacter() -- change "game.Workspace.Player" to variable for the actual player

m:LoadCharacter()

Hope I could be of help; good luck!

Log in to vote
0
Answered by 10 years ago

If you are using a LocalScript, you will be able to access the current player by the LocalPlayer property of the Players service.

local plr = game.Players.LocalPlayer

plr.Character:BreakJoints() -- kill character

Answer this question