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

Does the local player thingy works, or does it need to be changed?

Asked by 7 years ago

I don't know if this works, but is this right when I want to use "player"?

local player = game.Players.LocalPlayers

or does something need to be changed?

3 answers

Log in to vote
0
Answered by
PolyyDev 214 Moderation Voter
7 years ago

As long as it's a local script, yes. If you want to get the player from a regular script I would recommend putting it StarterGui and doing this:

local player = script.Parent.Parent -- Gets the parent of StarterGui, but when playing it would be the parent of PlayerGui so it would find the player.
Ad
Log in to vote
0
Answered by 7 years ago

You would use a LocalScript and write:

local Player = game.Players.LocalPlayer

http://wiki.roblox.com/index.php?title=API:Class/LocalScript

Log in to vote
0
Answered by 7 years ago

If you're in a LocalScript, your code is perfectly fine. For Scripts, you need to use the game.Players.PlayerAdded event (assuming you want to do something when a player is added to the game); you can learn from Roblox's leaderboard script (in the Toolbox) that uses this event and more.

Answer this question