|
| 20 Jul 2013 07:03 AM |
| How to get the local player of the click detector(the player who clicked it) |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
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
|
  |
| 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
|
  |
| Joined: 18 Jul 2013 |
| Total Posts: 2568 |
|
| |
|
|
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 20 Jul 2013 12:17 PM |
| Again, why create another variable? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 20 Jul 2013 12:29 PM |
| But... That's just absurd. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|
|
| 20 Jul 2013 12:38 PM |
| The Top answer is how I make of it all. |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 20 Jul 2013 01:31 PM |
| Though, you didn't get to any point. |
|
|
| Report Abuse |
|
|
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 |
|
|