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
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
| |
|
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
|
  |
| 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 |
|
|