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: Changing a Bool Value

Previous Thread :: Next Thread 
drgn42 is not online. drgn42
Joined: 11 Feb 2010
Total Posts: 3231
16 Nov 2014 06:26 PM
I was wondering if I could change a bool value to the opposite of what it is without using an if statement to check to see what it is. I have a constantly changing bool value, and I need to make it so when you click, it changes 3 bool values to the opposite of what they are, but I don't want to have to use 6 if statements to check each possible scenario. Help would be appreciated.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
16 Nov 2014 06:28 PM
bool = true

bool = not bool
Report Abuse
drgn42 is not online. drgn42
Joined: 11 Feb 2010
Total Posts: 3231
16 Nov 2014 06:30 PM
Well duh. But I'd still need to do this

if bool1 == true then
bool1 = false
return
end
if bool1 == false then
bool1 = true
return
end

if bool2 == true then
bool2 = false
return
end
if bool2 == false then
bool2 = true
return
end

if bool3 == true then
bool3 = false
return
end
if bool3 == false then
bool3 = true
return
end

What I'd rather do is

bool1 = opposite value
bool2 = opposite value
bool3 = opposite value

I just dont know how to do it.
Report Abuse
drgn42 is not online. drgn42
Joined: 11 Feb 2010
Total Posts: 3231
16 Nov 2014 06:31 PM
Unless you were saying bool = not bool was the answer. I think I see what you were saying now.
Report Abuse
drgn42 is not online. drgn42
Joined: 11 Feb 2010
Total Posts: 3231
16 Nov 2014 06:33 PM
Oh... Thanks. It does work.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
16 Nov 2014 06:34 PM
bool1 = not bool1
bool2 = not bool2
bool3 = not bool3

"not" negates boolean values.
print(not true)
>false
print(not false)
>true

So:
bool = true
bool = not bool
print(bool)
>false
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
16 Nov 2014 06:34 PM
You're welcome and sorry I was late :P
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