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 » Game Design
Home Search
 

Re: I need help understanding this if/then statement.

Previous Thread :: Next Thread 
JordanRaptor is not online. JordanRaptor
Joined: 14 Apr 2009
Total Posts: 21282
03 Mar 2015 11:51 AM
local enabled = false

if enabled then
print("enabled")
else
print("disabled")
end

While going over the Roblox Wiki Lua tutorial -maybe I'm over thinking it- I ran into an issue or means for concern. Would "disabled" be printed on the screen since enabled is rendered false, causing the compiler to overlook or skip the first function and printing the second (After, of course, it changes the high-level language into a low-level machine language)? Or am I just out of my mind..?
Report Abuse
HailMario is not online. HailMario
Joined: 05 Oct 2012
Total Posts: 17741
03 Mar 2015 11:55 AM
i think i know the answer.....











you have to leave friendpai

jk idk
Report Abuse
iAndreas is not online. iAndreas
Joined: 05 Feb 2015
Total Posts: 667
03 Mar 2015 11:56 AM
Local: "Enabled" is false (not enabled) so when it is enabled, it will display "Enabled" but if it's not (which it isn't at the start of the script) then it will display "Disabled."

iAndreas | The Providence
Report Abuse
cooldude816 is not online. cooldude816
Joined: 03 Jan 2009
Total Posts: 27759
03 Mar 2015 11:57 AM
you need local function enabled = false

lol
Report Abuse
JordanRaptor is not online. JordanRaptor
Joined: 14 Apr 2009
Total Posts: 21282
03 Mar 2015 11:59 AM
So it would print "Disabled", I see. In order to enable it and have it print "Enable", I'd have to make the statement true, yes?

local enabled = true

if enabled then
print("enabled")
else
print("disabled")
end
Report Abuse
cooldude816 is not online. cooldude816
Joined: 03 Jan 2009
Total Posts: 27759
03 Mar 2015 11:59 AM
local enabled isn't setting a function
Report Abuse
cooldude816 is not online. cooldude816
Joined: 03 Jan 2009
Total Posts: 27759
03 Mar 2015 12:00 PM
and you didn't set if enabled is what
so

local function enabled = false

if enabled = true then
print("enabled")
else
print("disabled")
end
Report Abuse
cooldude816 is not online. cooldude816
Joined: 03 Jan 2009
Total Posts: 27759
03 Mar 2015 12:03 PM
nvm ignore me

local function enabled()
enabled = false

if enabled = true then
print("enabled")
else
print("disabled")
end
Report Abuse
JordanRaptor is not online. JordanRaptor
Joined: 14 Apr 2009
Total Posts: 21282
03 Mar 2015 12:04 PM
So I'd have to use the "function" command to set or offset enable-ability and make it print either strings? If that's the case, what did the previous script I asked about do exactly?
Report Abuse
JordanRaptor is not online. JordanRaptor
Joined: 14 Apr 2009
Total Posts: 21282
03 Mar 2015 12:08 PM
DotDotDot.
Report Abuse
iAndreas is not online. iAndreas
Joined: 05 Feb 2015
Total Posts: 667
03 Mar 2015 12:13 PM
The first you posted made a function called enabled and made the value false, and if the value was true post enabled, unless it was false, it'd display disabled.

iAndreas | The Providence
Report Abuse
iAndreas is not online. iAndreas
Joined: 05 Feb 2015
Total Posts: 667
03 Mar 2015 12:14 PM
Sorry, wrong, you made a function called enabled, and made the value false, and you said if the function you made then "enabled", meaning your script doesn't exactly work.

iAndreas | The Providence
Report Abuse
JordanRaptor is not online. JordanRaptor
Joined: 14 Apr 2009
Total Posts: 21282
03 Mar 2015 12:14 PM
Okay, so I had it right the first go round. Cool was somewhat confusing me. :(
Report Abuse
JordanRaptor is not online. JordanRaptor
Joined: 14 Apr 2009
Total Posts: 21282
03 Mar 2015 12:15 PM
My brain can't take much more of these wishy-washy explanations. :(
Report Abuse
iAndreas is not online. iAndreas
Joined: 05 Feb 2015
Total Posts: 667
03 Mar 2015 12:19 PM
OK I'll break it down. (I'm not an expert at scripting, but I edit them, so I may not be 100% accurate.)

local enabled = false <-- You've got the local function "enabled" and you've made the value false.

if enabled then <-- Then you're saying, if the local function "enabled" then print "enabled.", so you're saying if the function exists or somewhat, then print enabled.
print("enabled")
else
print("disabled") <-- But if it doesn't exist, post disabled.
end

iAndreas | The Providence
Report Abuse
iAndreas is not online. iAndreas
Joined: 05 Feb 2015
Total Posts: 667
03 Mar 2015 12:20 PM
This will work.

local function enabled() <-- There it's getting the function "enabled."
enabled = false <-- Making it false.

if enabled = true then <-- If it's not false (true) then print enabled.
print("enabled")
else
print("disabled") <-- If it's false then print disabled.
end

iAndreas | The Providence
Report Abuse
cooldude816 is not online. cooldude816
Joined: 03 Jan 2009
Total Posts: 27759
03 Mar 2015 03:25 PM
if you haven't set enabled as a function already your code won't work and mine will
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
03 Mar 2015 03:34 PM
enabled = true

if enabled == true then
print("enabled")
else
print("enabled is false")
end


-- you need to use == when you check for a value and = when you set a value
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
03 Mar 2015 03:35 PM
function???

wtf???
that's not what he was asking for
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
03 Mar 2015 03:36 PM
i wonder if these people are trolling or just putting random stuff
Report Abuse
GodShowsTheWay is not online. GodShowsTheWay
Joined: 27 Oct 2014
Total Posts: 7180
03 Mar 2015 03:39 PM
enabled is a variable and not a function

>_>

its a bool variable that has a true or false value
Report Abuse
cooldude816 is not online. cooldude816
Joined: 03 Jan 2009
Total Posts: 27759
03 Mar 2015 03:45 PM
oh
i was getting variables and functions confused

cos he used local enable
Report Abuse
RobuxLife is not online. RobuxLife
Joined: 19 Sep 2012
Total Posts: 13336
03 Mar 2015 03:47 PM
local enabled = false -- you made a local variable named enabled

if enabled then -- if enabled = true or exists or whatever then
print("enabled") -- print enabled
else -- if it's not true then
print("disabled") -- print disabled
end
Report Abuse
JordanRaptor is not online. JordanRaptor
Joined: 14 Apr 2009
Total Posts: 21282
03 Mar 2015 03:56 PM
Ya, I'm in the boolean tutorial.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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