AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 21 Mar 2015 08:48 AM |
-- Equipped Function MouseButton1Down:connect(function() print'Running once' end) end) -- to the equipped function
I have a little problem. If you equip the tool and click, it prints once. If you re-equip and click, it prints twice. It runs it for each time you equip because the function never ends. How can I break this function so it will only run once in the future when you equip? |
|
|
| Report Abuse |
|
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
| |
|
|
| 21 Mar 2015 01:39 PM |
| That's because you are connecting it more than once, you could disconnect it but roblox says not to anymore, so you just log each time you equip it and if its the same then do the stuff, |
|
|
| Report Abuse |
|
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 21 Mar 2015 01:40 PM |
| My question is HOW do I disconnect it? |
|
|
| Report Abuse |
|
|
|
| 21 Mar 2015 01:42 PM |
You cant anymore it errors
local equips = 0
equp event equip +1 local curentequop=equip click if curentequop= equip then end end
|
|
|
| Report Abuse |
|
|
| |
|
AntiFiter
|
  |
| Joined: 14 May 2009 |
| Total Posts: 12290 |
|
|
| 21 Mar 2015 01:47 PM |
@Dog
It's just 'break'
And you can't break MouseButton1Down, you can only return. It's not a loop
I could do something like "if not equipped return end" right after the function, but that doesn't fix the problem. It will still run a new function every time you equip, which is going to get very laggy after playing for an hour.
any ideas? |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 21 Mar 2015 01:51 PM |
local event
Tool.Equipped:connect(function(mouse) event = mouse.Button1Down:connect(function() print'Running once' end) end)
Tool.Unequipped:connect(function() event:disconnect() end) |
|
|
| Report Abuse |
|
|