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 » Scripting Helpers
Home Search
 

Re: ClickDetector

Previous Thread :: Next Thread 
greatarchon999 is not online. greatarchon999
Joined: 09 Jun 2011
Total Posts: 772
20 Jul 2013 07:03 AM
How to get the local player of the click detector(the player who clicked it)
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 07:23 AM
Workspace.ClickDetector.Clicked:connect(function(player)
print(player.Name.. " has clicked the button.");
end)

♫ ♩ ♩ A long, long time ago, I can still remember how Roblox didn't have that argument. (the one that gets that player.) ♫ ♩ ♩
♩ And I knew that if I had my chance, I could make those developers dance. ♩
♩ And maybe they'd implement it for a while. ♩
♩ But Roblox made me shiver, with every script I'd deliver. ♩
♩ Bad news on the doorstep; ClickDetector couldn't take one more step. ♩
♩ I can't remember if Telamon cried when he read about its widowed wife. ♩
♩ But something touched him deep inside, the day the ClickDetector died. ♩
♩ So bye-bye, the Lua ClickDetector. ♩
♩ Drove my Lua to the levee, but the levee was dry. ♩
♩ And those good old boys were drinking MouseClick and GUIs ♩
♩ Singing "This will be the day that I die." ♩
♩ "This will be the day that I die. ♩
Report Abuse
CODsniperkid is not online. CODsniperkid
Joined: 17 Jul 2009
Total Posts: 872
20 Jul 2013 07:29 AM
You can't. The best thing you could do is to have a slightly larger block under the click Detector(where they would have to be standing to click it) and name it something like "detector", and make a seperate script with
`local debounce = false
function onTouch(hit)
if debounce == false then
debounce = true
if hit.Parent:findFirstChild("Humanoid") then
STRINGVALUE.Value = hit.Parent.Name--Replace STRINGVALUE with the location of a StringValue object
end
wait(1)
debounce = false
end
end
script.Parent.Touched:connect(onTouch)`
and have it disabled for the time being.

Then you could have this script in the click detector
`function onClick()
TOUCHBLOCK.Script.Disabled = false--Replace TOUCHBLOCK with the location of the block with the script above
wait(2)--Let the Touchblock have some time.
print(STRINGVALUE.Value)--Replace STRINGVALUE with the location of the StringValue object used in the first script.
end
script.Parent.ClickDetector.MouseClick:connect(onClick)`

Hope it helps!
Report Abuse
CODsniperkid is not online. CODsniperkid
Joined: 17 Jul 2009
Total Posts: 872
20 Jul 2013 07:33 AM
Oh, guess I'm still living in '09. Dang. Better brush up on the changes! Sorry, listen to the guy above me xD
Report Abuse
CODsniperkid is not online. CODsniperkid
Joined: 17 Jul 2009
Total Posts: 872
20 Jul 2013 07:43 AM
Actually, your script has a wrong Listening event.

`Workspace.ClickDetector.MouseClick:connect(function(player)
print(player.Name.. " has clicked the button.");
end)`
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
20 Jul 2013 07:46 AM
^hen
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 07:49 AM
Oh yes, you're quite correct. My apologies, I was simultaneously working with plugins, which uses the Click event. I knew it was different in some way.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
20 Jul 2013 09:01 AM
@Absurdism. Oh yes, I remember those days where click detectors couldn't detect who clicked it... That's when I was forced to use tools instead, and now I see click detectors useless.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 11:46 AM
2007-2009 forever.
Report Abuse
stephen1182 is not online. stephen1182
Joined: 31 Aug 2010
Total Posts: 4003
20 Jul 2013 12:07 PM
This is the easiest method:

ClickDetector.MouseClick:connect(function(click)
local player = game.Players:GetPlayerFromCharacter(click.Parent)
if player then
print(player.Name.." has clicked ClickDetector.")
end
end)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 Jul 2013 12:12 PM
@Stephen

No. . . Even if that worked, how is it easier than using just the parameter instead of creating a variable?
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 12:16 PM
Oh, now that we're on that subject, this is the most efficient, easiest method:

ClickDetector.MouseClick:connect(function(click)
local player = Game.Players[click.Name]
assert(player)
print(player.Name.." has clicked ClickDetector.")
end)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 Jul 2013 12:17 PM
Again, why create another variable?
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 12:28 PM
Easier access to the Player object. It depends on your application.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 Jul 2013 12:29 PM
But... That's just absurd.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
20 Jul 2013 12:30 PM
^ but that's just ABSURD. It returns the player for you, you don't need to make another variable for it
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 12:31 PM
Yes, quite so. Absurd in such a way that the human, who seeks endless knowledge and never finds anything to be truly certain. Nothing can be proven. Everything is absurd, don't you see? Unconventional.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 12:32 PM
Oh, does it? I thought it returned the character. I am so not up-to-date with these event arguments.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
20 Jul 2013 12:33 PM
Things can be proven. Things have been proven. Logic is very provable. Not everything is absurd. But you sir, are. You wreak of absurdity in your quest to prove everything as absurd. Absurdism.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 Jul 2013 12:33 PM
parameter
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
20 Jul 2013 12:35 PM
@"parameter vs argument" debate:

http://stackoverflow.com/questions/3176310/difference-between-parameter-and-argument
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
20 Jul 2013 12:38 PM
The Top answer is how I make of it all.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 01:26 PM
Logic is provable, but it is human-made. Everything existed before essence, because humans gave essence to all existence. You cannot know if we are puppets, being controlled by some greater force, or if we have free will. Let us say you shout out, unprovoked, to see if the world would respond to your actions, as if they are the charade of the great marionette as well. Those actions are part of the puppetry as well. Nothing can be known for sure. Nothing could be real. Your mind develops intuition, thinking that whenever we turn around, we should know what to expect. That's wrong. You can't know. It is improbable that a vortex would have opened ajar from the abyss, winding up at your doorstep, but it is probable that something completely and utterly different could happen. Being up-to-date with knowledge is impossible, but knowledge lasts forever. Therefore, seeking knowledge is impractical and an infinite loop of idiocy.

inb4 permaban for discussing ideology in the scripting helpers forum
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
20 Jul 2013 01:31 PM
Though, you didn't get to any point.
Report Abuse
Absurdism is not online. Absurdism
Joined: 18 Jul 2013
Total Posts: 2568
20 Jul 2013 01:32 PM
The point is that there is no point to anything. [/paradox]
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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