DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 12 Aug 2016 12:06 PM |
Hey, does anyone know if you can have multiple class events within a single function?
For example:
on = false
Part.ClickDetector.MouseClick:connect(function(onClick) --code related to clickdetector here on = true end)
How would I make it so that on = true is activated when someone touches a brick without it going outside of the function? Sorry if this sounds vague, I'm not really sure how to describe it. |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
| |
|
Xsitsu
|
  |
| Joined: 28 Jul 2009 |
| Total Posts: 2921 |
|
|
| 12 Aug 2016 12:17 PM |
| Like, you want some other event that is not ClickDetector.MouseClick to be able to set your variable "on" to true? |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 12 Aug 2016 12:19 PM |
| Yeah, but within the same function. Is there a way to do that? |
|
|
| Report Abuse |
|
|
Xsitsu
|
  |
| Joined: 28 Jul 2009 |
| Total Posts: 2921 |
|
|
| 12 Aug 2016 12:20 PM |
| What do you mean by some other event within the same function? |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
| |
|
Xsitsu
|
  |
| Joined: 28 Jul 2009 |
| Total Posts: 2921 |
|
|
| 12 Aug 2016 12:27 PM |
| So, you want a Touched event to be able to do the exact same thing that your MouseClick event does currently? Or do you just want the Touched event to set "on" to true? I am not having an easy time understanding your explanation. |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 12 Aug 2016 12:33 PM |
| I want the touched event to set "on" to true. |
|
|
| Report Abuse |
|
|
Xsitsu
|
  |
| Joined: 28 Jul 2009 |
| Total Posts: 2921 |
|
|
| 12 Aug 2016 12:38 PM |
| Okay. Then since "on" is a global variable that is not limited to the scope of MouseClick, you could just straight up have the Touched event set "on" to true and if MouseClick tried to read that value it would read true. |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 12 Aug 2016 12:45 PM |
| But how would I put two class events into one function? |
|
|
| Report Abuse |
|
|
Xsitsu
|
  |
| Joined: 28 Jul 2009 |
| Total Posts: 2921 |
|
|
| 12 Aug 2016 12:46 PM |
local on = false
Part.ClickDetector.MouseClick:connect(function(onClick) --code related to clickdetector here on = true end)
Part.Touched:connect(function(hit) --code related to touch here on = true end) |
|
|
| Report Abuse |
|
|
DarkComa
|
  |
| Joined: 01 Apr 2011 |
| Total Posts: 11679 |
|
|
| 12 Aug 2016 12:55 PM |
| It's not exactly what I meant, but it's my fault for wording it so poorly. Thanks for the help, though. I think I've figured it out. |
|
|
| Report Abuse |
|
|