|
| 12 Dec 2014 12:45 AM |
I'm trying to do
until RemoveS.MouseButton1Click:connect(function()
-- end) not working.. |
|
|
| Report Abuse |
|
|
| |
|
LPGhatguy
|
  |
 |
| Joined: 27 Jun 2008 |
| Total Posts: 4725 |
|
|
| 12 Dec 2014 01:02 AM |
I believe what you're trying to do is
RemoveS.MouseButton1Click:wait() -- do things here |
|
|
| Report Abuse |
|
|
|
| 12 Dec 2014 01:05 AM |
| That's close, but instead of repeating until the button is clicked, it repeats everytime it is clicked. |
|
|
| Report Abuse |
|
|
| |
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 12 Dec 2014 01:52 AM |
Are you trying to make it repeat something until the mouse is up?
Like click and hold? |
|
|
| Report Abuse |
|
|
SLY3
|
  |
| Joined: 10 Jul 2008 |
| Total Posts: 1700 |
|
|
| 12 Dec 2014 09:29 AM |
Do you mean until the event occurs? If so, then you don't need repeat wait(), you just do the function:
-- RemoveS.MouseButton1Click:connect(function()
end) --
And it will wait until the MouseButton1Click event has occurred. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 12 Dec 2014 01:55 PM |
@Sly3 Actually, no RemoveS.MouseButton1Click:wait()
Would wait until its fired |
|
|
| Report Abuse |
|
|
|
| 12 Dec 2014 03:51 PM |
naw that's what the other guy said
i mean like
repeat ---
until mouse gets clicked |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Dec 2014 03:52 PM |
'RemoveS.MouseButton1Click:wait()'
What 128 said is correct if you are doing it correctly |
|
|
| Report Abuse |
|
|
|
| 12 Dec 2014 03:53 PM |
| i know but it doesn't match the method i am going for. I need something to keep repeating and immediately stop if the mouse is clicked |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Dec 2014 03:59 PM |
oh. there is probably a better way to do this
local x = true; coroutine.wrap(function() blah.MouseButton1Click:wait(); x = false; end)();
while x do --stuff end |
|
|
| Report Abuse |
|
|
|
| 12 Dec 2014 03:59 PM |
| i might use that but is there a way to do it with repeat? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 12 Dec 2014 04:57 PM |
Avoiding coroutines like a moron:
local gotclickedWoop = false local this = RemoveS.MouseButton1Click:connect(function() gotclickedWoop =true; this:disconnect() this=nil; end) repeat something until gotclickedWoop gotclickedwoop=nil |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Dec 2014 04:58 PM |
| Nah, disconnect is for losers :) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 12 Dec 2014 11:42 PM |
local this = RemoveS.MouseButton1Click:connect(function() gotclickedWoop =true; this:disconnect() this=nil; end)
That wouldn't work
local this; this = RemoveS.MouseButton1Click:connect(function() gotclickedWoop =true; this:disconnect() this=nil; end) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 13 Dec 2014 08:13 AM |
| I think it would work, because by the time the connection has returned it is still allowed access to the scope it was made in because of closures. |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 13 Dec 2014 11:38 AM |
| You would think it would, and it definitely should, but it doesn't |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 13 Dec 2014 11:43 AM |
Example
local object = Instance.new("Model") local self = object.Changed:connect(function() self:disconnect() end) wait(3) object.Name = "model" -->local self = object.Ch:3: attempt to index global 'self' (a nil value)
But if you swap it to local self; self = blah You get no error
This isn't a logical type thing, I only know it because I've done it before |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 13 Dec 2014 03:21 PM |
| It doesn't work because the variable is declared AFTER 'self:disconnect()' meaning nil:disconnect() meaning AHH!!1 |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 13 Dec 2014 03:34 PM |
.-. Fine it would work if self was not local |
|
|
| Report Abuse |
|
|