I know you can't use localplayer in a normal script, so I need to know what other way I can find the player in this script, i'm just used to using local scripts, thank you if you can help.
script.Parent.MouseClick:connect(function() --The Parent of this is a Click Detector local Player = game.Players.LocalPlayer
The MouseClick
event of a ClickDetector
passes the player who clicked the button (playerWhoClicked
, for example) as the first argument of the callback function.
script.Parent.MouseClick:connect(function(playerWhoClicked) local Player = playerWhoClicked -- you don't even need this line. just use playerWhoClicked directly --TODO: Rest of the code end)
For more details, please take a look at the wiki page for the MouseClick event, it also has another example: http://wiki.roblox.com/index.php?title=API:Class/ClickDetector/MouseClick
The event MouseClick
has a argument that is the player who clicked, you can use the argument to determine which player clicked the ClickDetector
. Note that this doesn't work with FilteringEnabled
turned on.
script.Parent.MouseClick:connect(function(playerWhoClicked) -- Do what you need to do... end)