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 » Scripting Helpers
Home Search
 

Re: On and Off

Previous Thread :: Next Thread 
KingJacko is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
05 Nov 2013 05:35 AM
Im trying to make a light turn on and off by clicking. The first time i click, i want it on. The second, off.
This is my hierarchy:

Workspace
-GlowyPart
PointLight
-Clicker
ClickDetector
Script

this is the script above

function onClicked(playerWhoClicked)
game.Workspace.GlowyPart.PointLight.Enabled = true
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

so i have the first part and it works. I dont know how to make it turn off on click again. Can you help me?
Report Abuse
KingJacko is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
05 Nov 2013 06:04 AM
hello?
bump
Report Abuse
Truste135 is not online. Truste135
Joined: 26 Oct 2010
Total Posts: 741
05 Nov 2013 06:39 AM
add a boolean
once you click it
turn the boolean to true
then

function onClicked()
if clicked == true then
//do your work here
else
//do nothing
end

ɪ ᴛʜʀᴇᴡ ᴛʜᴇ ʀᴇᴘʟᴀʏ ʙᴜᴛᴛᴏɴ ɪɴ ᴛʜᴇ ᴛʀᴀsʜ, ɢᴏ ʟᴏᴏᴋ ғᴏʀ ɪᴛ.
Report Abuse
Truste135 is not online. Truste135
Joined: 26 Oct 2010
Total Posts: 741
05 Nov 2013 06:47 AM
correction

ifClicked = false

function onClicked(playerWhoClicked)
if ifClicked = false then
game.Workspace.GlowyPart.PointLight.Enabled = true
end
ifClicked = true
if ifClicked = true then
game.Workspace.GlowyPart.PointLight.Enabled = false
ifClicked = false
end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

ɪ ᴛʜʀᴇᴡ ᴛʜᴇ ʀᴇᴘʟᴀʏ ʙᴜᴛᴛᴏɴ ɪɴ ᴛʜᴇ ᴛʀᴀsʜ, ɢᴏ ʟᴏᴏᴋ ғᴏʀ ɪᴛ.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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