|
| 17 Nov 2014 03:57 PM |
I'm making my own weapon system as a bit of a project, but I've run into a problem (evidently).
If you deselect and reselect the weapon, then when you click the function to fire the weapon runs multiple times (the number of times you've reselected the weapon) in one instance. Does anyone have any ideas as to how to stop this?
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2014 04:01 PM |
| You are connecting events every time you select it I'm guessing. |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2014 04:02 PM |
| Unfortunately we're not omniscient (or even clairvoyant), and as such have no idea what your code looks like, and as such have no way of knowing what even causes this, much less how to fix it . |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2014 04:07 PM |
Pig assumes correctly. It's the only way I can think of doing it (other scripts I've seen do similar things).
Basically, it looks like this:
function fire(*args) --boom boom pow end
tool.Equipped:connect(function(mouse) mouse.Button1Down:connect(fire) end)
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2014 04:11 PM |
I thought about doing something like
equipped = false
mouse.Button1Down:connect(function(*args) if equipped then --boom boom pow end end)
tool.Equipped:conenct(function(mouse) equipped = true end)
tool.Unequipped:conenct(function(mouse) equipped = false end)
but mouse is nil :/
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|