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: Okay, a few questions, I'm new to Lua.

Previous Thread :: Next Thread 
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:14 PM
I'm a bit unsure about booleans.
I'm reading roblox wiki, and I think that booleans are true/false values, correct?

So, for example, is this script a boolean?

local forum = true
if forum == true then
print ("I got this right!")
else
print ("I need more practice.")
end


Sorry for the trouble, this to you guys is probably child's play, but everyone has to start somewhere, right?

I come from LMaD, but I'm looking to retire to building and scripting.
Report Abuse
CoolioTree is not online. CoolioTree
Joined: 26 Dec 2012
Total Posts: 2509
16 Jul 2014 04:17 PM
A boolean is a variable that's either true or false. It's also a type of algebra, but you don't have to worry about that.
Report Abuse
IAmTheRolo is online. IAmTheRolo
Joined: 12 Nov 2013
Total Posts: 859
16 Jul 2014 04:17 PM
That would work, yes. But you can also do this and still get the same outcome (it is optional):

local forum = true
if forum then
print("Yay")
else
print("No!")
end

In other words, the conditional is translated to: if true then, as forum is just a variable for true.
Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:18 PM
Can a boolean be a 1 or 2 value?

Like --

local forum = 1
if forum == 1 then
print ("1")
elseif
print ("2")
else
print ("3")
end
Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:20 PM
Ohhhh, so the '== true' is assumed, that makes sense.
Would that be the same for '== false' or would you need to specify that it's equals false?
Report Abuse
CoolioTree is not online. CoolioTree
Joined: 26 Dec 2012
Total Posts: 2509
16 Jul 2014 04:20 PM
No, it had to be either true or false.
Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:21 PM
Okay, so this script below is just a conditional, not a boolean, correct?

---------------------
local forum = 1
if forum == 1 then
print ("1")
elseif
print ("2")
else
print ("3")
end
---------------
Report Abuse
CoolioTree is not online. CoolioTree
Joined: 26 Dec 2012
Total Posts: 2509
16 Jul 2014 04:21 PM
Oh, and you have to specify if it has to be false. Yeah.
Report Abuse
CoolioTree is not online. CoolioTree
Joined: 26 Dec 2012
Total Posts: 2509
16 Jul 2014 04:22 PM
You have to have a condition for else is too.
Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:23 PM
Thanks Coolio, I'm slowly learning. :D
My goal is to know how to click on a brick, make it .5 transparency, then click it again to go back to 0 transparency.
Report Abuse
CoolioTree is not online. CoolioTree
Joined: 26 Dec 2012
Total Posts: 2509
16 Jul 2014 04:23 PM
Elseif*
Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:24 PM
What do you mean a condition for elseif?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Jul 2014 04:25 PM
if statement then

elseif statement2 then

elseif statement3 then

else

end
Report Abuse
CoolioTree is not online. CoolioTree
Joined: 26 Dec 2012
Total Posts: 2509
16 Jul 2014 04:25 PM
For elseif, you have to do the same thing that you did with if.
Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:26 PM
local forum = 1
if forum then
print ("true")
elseif forum == false then
print ("false")
else
print ("neither")
end

^ like that?
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Jul 2014 04:27 PM
yes

also you can do

elseif not forum then

Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:27 PM
Oops, forgot to change local forum to true.

How about this?

local forum = true
if forum then
print ("true")
elseif forum == false then
print ("false")
else
print ("neither")
end
Report Abuse
CoolioTree is not online. CoolioTree
Joined: 26 Dec 2012
Total Posts: 2509
16 Jul 2014 04:27 PM
Yes, you're doing awesome! :)
Report Abuse
superspy468 is not online. superspy468
Joined: 29 May 2009
Total Posts: 53408
16 Jul 2014 04:28 PM
I think I really understand booleans now. :D
Time to move onto strings. ;)
Report Abuse
DerProgrammierer is not online. DerProgrammierer
Joined: 16 Aug 2007
Total Posts: 12992
16 Jul 2014 04:43 PM
Conditions in if-statements are booleans. You can look at if statements under-the-hood function that will only return true or false depending on the answer. If you can't make a true or false statement in the condition, then it's not a condition.

local s = 1

if s == 1 then -- true
end

if s == 2 then -- false
end
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