|
| 02 Jan 2016 06:48 PM |
So EVERY time I make a script that has "else" in it, it doesn't work, and It is probably because I am using it in the wrong way, let me show you how I type it:
function onClicked() if tonumber(script.Parent.Parent.Parent.Open.Value) == false then script.Parent.Parent.Parent.Open.Value = true else script.Parent.Parent.Parent.Open.Value = false end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
When I click, the "Open" value gets set to true, but then when I click it again, it doesn't turn back! Can someone teach me how to properly use the else function?
Sorry, I am a new scripter!
|
|
|
| Report Abuse |
|
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
| |
|
| |
|
|
| 02 Jan 2016 06:52 PM |
Don't listen to Lice, he doesn't know what he's talking about. Don't use elseif here, it is uselessly being inefficient.
function onClicked() if script.Parent.Parent.Parent.Open.Value == false then script.Parent.Parent.Parent.Open.Value = true else script.Parent.Parent.Parent.Open.Value = false end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Also, you might try this
function onClicked() script.Parent.Parent.Parent.Open.Value = not script.Parent.Parent.Parent.Open.Value end
|
|
|
| Report Abuse |
|
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
|
| 02 Jan 2016 06:52 PM |
Well...
Say I bad a condition: If x == 5 then print ("uo") elseif x == 20 then print ("awye")
Make x 20 and see what happens. |
|
|
| Report Abuse |
|
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
| |
|
|
| 02 Jan 2016 06:54 PM |
| How does elseif help here? That makes it less efficient while doing the same thing. |
|
|
| Report Abuse |
|
|
jmt99
|
  |
| Joined: 27 Jul 2008 |
| Total Posts: 4799 |
|
|
| 02 Jan 2016 06:54 PM |
Lice, obviously you would use elseif in that condition, but If you would actually read OP's thread, you would realise an elseif would be useless, because he is checking for true or false.
#code --jmt99 |
|
|
| Report Abuse |
|
|
triode
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 5844 |
|
|
| 02 Jan 2016 06:55 PM |
elseif is good for bools...
Its not good for anything else unless you use an else |
|
|
| Report Abuse |
|
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
| |
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
|
| 02 Jan 2016 06:55 PM |
| OP seems to be checking a boolean value, else is fine :p |
|
|
| Report Abuse |
|
|
| |
|
triode
|
  |
| Joined: 13 Aug 2011 |
| Total Posts: 5844 |
|
|
| 02 Jan 2016 06:55 PM |
Wait nvm...
I c what happened lmao |
|
|
| Report Abuse |
|
|
jmt99
|
  |
| Joined: 27 Jul 2008 |
| Total Posts: 4799 |
|
|
| 02 Jan 2016 06:56 PM |
>elseif is good for bools...
How so? There is only 2 values in which a boolean can be. True or false. So therefor, you only need to check if its true or false, and then put an ELSE statement, which would result in the other boolean.
#code --jmt99 |
|
|
| Report Abuse |
|
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
| |
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
| |
|
| |
|
jmt99
|
  |
| Joined: 27 Jul 2008 |
| Total Posts: 4799 |
|
|
| 02 Jan 2016 06:58 PM |
Lice you're very ignorant.
#code --jmt99 |
|
|
| Report Abuse |
|
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
|
| 02 Jan 2016 06:59 PM |
Your mom is very ignorant
She was suxin my d and she was being ignorant not to swallow |
|
|
| Report Abuse |
|
|
DrHaximus
|
  |
| Joined: 22 Nov 2011 |
| Total Posts: 8410 |
|
| |
|
|
| 02 Jan 2016 07:00 PM |
@lice
wiki.roblox.com >tutorials >scripting |
|
|
| Report Abuse |
|
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
| |
|
|
| 02 Jan 2016 07:08 PM |
| Definitely trolling at this point. |
|
|
| Report Abuse |
|
|
| |
|
LicePro
|
  |
| Joined: 08 Dec 2015 |
| Total Posts: 467 |
|
| |
|