Ulrond
|
  |
| Joined: 23 Jun 2011 |
| Total Posts: 11962 |
|
|
| 04 Apr 2015 12:47 PM |
Is there a way to get a player's name in Players when they click a part using ClickDetector?
I'm writing a script, that when a part is clicked, an item in leaderstats will go up by 1. |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 04 Apr 2015 01:07 PM |
part.ClickDetector.MouseClick:connect(function(player) end)
The MouseClick event returns the player that clicked it |
|
|
| Report Abuse |
|
|
Ulrond
|
  |
| Joined: 23 Jun 2011 |
| Total Posts: 11962 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
| |
|
draky251
|
  |
| Joined: 16 Dec 2011 |
| Total Posts: 28 |
|
|
| 05 Apr 2015 04:45 AM |
(I'm not too sure)
Part.MouseClick.Clicked:connect(function(Player) local ThePlayer = GetPlayerFromCharacter(Player) local Leaderstats = ThePlayer:WaitForChild("leaderstats") Leaderstats.Points = Leaderstats.Points + 1 end)
|
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 05 Apr 2015 04:47 AM |
draky please stop
you're just breaking code left, right and center
GetPlayerFromCharacter(Player)
that line shouldn't even exist
|
|
|
| Report Abuse |
|
|
|
| 05 Apr 2015 05:27 AM |
One thing you should note however, is that with FilteringEnabled, this will most likely break (unless you use a LocalScript for this (then the player already exists as LocalPlayer anyway)).
@draky, not only should this line not exist, but it's entirely wrong: GetPlayerFromCharacter(Player)
Should be game.Players:GetPlayerFromCharacter()
Also, the ClickDetector returns the player, not the character. |
|
|
| Report Abuse |
|
|