generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Class Event Issue

Previous Thread :: Next Thread 
DarkComa is not online. 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 is not online. DarkComa
Joined: 01 Apr 2011
Total Posts: 11679
12 Aug 2016 12:10 PM
Bump1.
Report Abuse
Xsitsu is online. 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 is not online. 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 is online. 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 is not online. DarkComa
Joined: 01 Apr 2011
Total Posts: 11679
12 Aug 2016 12:25 PM
A touched class event.
Report Abuse
Xsitsu is online. 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 is not online. 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 is online. 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 is not online. 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 is online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image