generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Get Player from ClickDetector?

Previous Thread :: Next Thread 
Ulrond is not online. 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 is not online. 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 is not online. Ulrond
Joined: 23 Jun 2011
Total Posts: 11962
05 Apr 2015 02:28 AM
How do I get the player?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
05 Apr 2015 02:30 AM
print(player.Name)
Report Abuse
draky251 is not online. 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 is not online. 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
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image