Dino77
|
  |
| Joined: 06 Apr 2008 |
| Total Posts: 748 |
|
|
| 05 Aug 2011 07:22 PM |
I've tried to make a script where you click the script's parent, and it makes another child (Light) within that parent unanchore when clicked, then if it is clicked again, for it to anchore, then unanchore (ect.) I'm confused though, and I don't know where I messed up:
Light = script.Parent.Light
function OnClicked()
Light.Anchored = false
else
Light.Anchored = true
Fanswitch.ClickDetector.MouseClick:connect(OnClicked) |
|
|
| Report Abuse |
|
|
robotmega
|
  |
| Joined: 16 May 2009 |
| Total Posts: 14084 |
|
|
| 05 Aug 2011 08:08 PM |
Light = script.Parent.Light
function OnClicked()
Light.Anchored = false
else
Light.Anchored = true
script.Parent.ClickDetector.MouseClick:connect(OnClicked) |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2011 08:10 PM |
Light = script.Parent.Light function onClicked() if Light.Anchored == false then Light.Anchored = true elseif Light.Anchored == true then Light.Anchored = false end end scirpt.Parent.ClickDetector.MouseClick:connect(onClicked)
(: |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2011 08:10 PM |
you never have a first "if" else is like a last resort kind off thing to think about the computer is reading this going "What am i suppose to do before having to unanchor "light"?"
so working script
Light = script.Parent.Light
function OnClicked()
if Light.Anchored == true then
Light.Anchored = false end
else Light.Anchored = true
Script.Parent.ClickDetector.MouseClick:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 05 Aug 2011 08:11 PM |
*edit*
else Light.Anchored = true end
*oops* |
|
|
| Report Abuse |
|
|