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 » Scripters
Home Search
 

Re: Just a question about Button1Down...

Previous Thread :: Next Thread 
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 01:12 PM
I've been having trouble here: http://www.roblox.com/Forum/ShowPost.aspx?PostID=70913988

So I just wanted to know, if an "if" statement has already been run correctly, will the script stop or keep on going?





~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
Megamatrixdude is not online. Megamatrixdude
Joined: 06 Dec 2009
Total Posts: 10939
28 Jun 2012 01:15 PM
Well that's a stupid question. I can answer it with yes and no, because the if in the examples below run correctly:

if true then
--blah
end

if not false then
--blah
end

if false then
--blah
end
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 01:16 PM
I still don't think you answered my question. I'm using "elseif" which doesn't require an extra end, so if the first "if" statement is finished running, will the others continue?






~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
28 Jun 2012 01:25 PM
I don't think you're really stepping through this logic:

local condition = 0

if condition == 0 then
print("0")
elseif condition == 1 then
print("1")
end


Obviously, it'll only print 0 because only condition == 0 is true. Lua's evaluator is lazy, so if the first one is true, it won't even evaluate the rest - but I could be wrong on that.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 01:27 PM
So I would have to make separate "if" statements just so I can run through a huge checklist? Or is there some kind of magical "and if" or "and" thing I could use?






~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
28 Jun 2012 01:30 PM
No, what you're doing should be working just like you want it.......from the looks...
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 01:31 PM
Then it looks like something else must be messing up, because the script I made isn't disabling Script1 at all.





~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
28 Jun 2012 01:37 PM
[ Content Deleted ]
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 01:40 PM
Because it is an Options GUI. Script1 is basically a script with onKeyDowns, and they are supposed to be Classic Controls. Then Script2 is another set of different controls, and I need it so if Script1 is already Disabled, to just close the GUI. If it isn't, then to Enable it and to close the GUI. But I also need Script2 to become Disabled if Script1 gets Enabled, and if it is already Disabled to do nothing. That's why.








~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
28 Jun 2012 01:45 PM
Basic rule of thumb: if you need a big long list of if-then statements, there's probably some way you could do it a lot better.
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 03:01 PM
Well, this is what I came up with after somebody suggested using "and":

    local playr = Game.Players.LocalPlayer
frame = script.Parent.Parent
Selection1 = playr.Backpack.LinkedPaintballGun.Script1
Selection2 = playr.Backpack.LinkedPaintballGun.Script2
function onClicked()

if (Script1.Disabled == false) and (Script2.Disabled == true) then --first possibility
frame.Visible = false
end --if it runs correctly, end the "if" statement

elseif (Script1.Disabled == true) and Script2.Disabled == true) then --second possibility
Script1.Disabled = false
frame.Visible = false
end --if it runs correctly, end the "if" statement started in the beginning

elseif (Script1.Disabled == false) and (Script2.Disabled == false) then --third possibility
Script2.Disabled = true
frame.Visible = false
end --if it runs correctly, end the "if" statement started in the beginning

elseif (Script1.Disabled = true) and (Script2.Disabled == false) then --fourth possibility
Script2.Disabled = true
Script1.Disabled = false
frame.Visible = false
end --if it runs correctly, end the "if" statement started in the beginning

end --ending the Clicked function

script.Parent.MouseButton1Down:connect(onClicked)





~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
28 Jun 2012 03:28 PM
[ Content Deleted ]
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 03:30 PM
Ok, Oysi. How about you go learn to be nice, and THEN you reply. Because clearly you don't realize everybody messes up. I realized I messed up the "if" statements and I fixed it now.

You act like everybody knows everything about scripting. Not everyone can now this. Go away, or learn to be nice. I obviously know something, or this script wouldn't be here.






~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 03:33 PM
And you need to learn to respect when people are still learning. What you did is like telling a kindergartner to go away and that they know nothing because they can't do algebra.





~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
28 Jun 2012 03:33 PM
[ Content Deleted ]
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
28 Jun 2012 03:36 PM
[ Content Deleted ]
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 03:37 PM
I fixed it a long time ago. It works now.


local playr = Game.Players.LocalPlayer
frame = script.Parent.Parent
Selection1 = playr.Backpack.LinkedPaintballGun.Script1
Selection2 = playr.Backpack.LinkedPaintballGun.Script2
function onClicked()

if (Selection1.Disabled == false) and (Selection2.Disabled == true) then
frame.Visible = false

elseif (Selection1.Disabled == true) and (Selection2.Disabled == true) then
Selection1.Disabled = false
frame.Visible = false

elseif (Selection1.Disabled == false) and (Selection2.Disabled == false) then
Selection1.Disabled = true
frame.Visible = false

elseif (Selection1.Disabled == true) and (Selection2.Disabled == false) then
Selection2.Disabled = true
Selection1.Disabled = false
frame.Visible = false
end

end

script.Parent.MouseButton1Down:connect(onClicked)






~"If I win the lottery, the first thing I'm buying is an optical mouse"~
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
28 Jun 2012 03:59 PM
@oysiaboutnoquestions

lol
so u r not supposed to ask anything?
but then its just diary stuff..
so you're not allowed to ask peoples' thoughts about ur concepts
okey..
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
28 Jun 2012 04:07 PM
Umm.. Respect? Math master Oysi doesn't has to respect anyone, even other scripters.
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
28 Jun 2012 05:28 PM
@su8

I always just say discuss at the end of my posts :3 No questions :P
Report Abuse
Oloek is not online. Oloek
Joined: 26 Jun 2012
Total Posts: 47
28 Jun 2012 08:18 PM
GreenDay, Oysi is right. You should learn how to script.

~Oloek
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
28 Jun 2012 08:20 PM
Oysi is alwayz rite..
Report Abuse
GreenDay987 is not online. GreenDay987
Joined: 21 May 2011
Total Posts: 7027
28 Jun 2012 08:49 PM
He is not right. As I already stated, not everyone knows how to script right off the bat, and just because I made a mistake doesn't mean I don't know how to script.
Report Abuse
Oloek is not online. Oloek
Joined: 26 Jun 2012
Total Posts: 47
28 Jun 2012 08:53 PM
We never said that making a mistake means you can't script.
Your argument is invalid.

~Oloek
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
28 Jun 2012 08:55 PM
Your invalid is argument
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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