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: Button not working first time -

Previous Thread :: Next Thread 
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
23 Sep 2014 12:32 PM
I'm clicking on my gui imagebutton the first time, and it doesn't do anything.
I click it a second time, and the script runs. Why doesn't it do it the first time?

menu = script.Parent.Parent.MenuFrame

function open()
menu.Visible = true
on = true
menu.Profile:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Inventory:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.BuyPoints:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Uniform:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
on = false
end

function close()
on = true
menu.Profile:TweenPosition(UDim2.new(-1,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Inventory:TweenPosition(UDim2.new(1,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.BuyPoints:TweenPosition(UDim2.new(-1,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Uniform:TweenPosition(UDim2.new(1,0,0,0),"Out","Bounce",1,true)
wait(1)
menu.Visible = false
on = false
end

script.Parent.MouseButton1Click:connect(function()
if menu.Visible == false and on == false then
open()
elseif menu.Visible == true and on == false then
close()
end
end)


"Et tu, Brute? Then fall, Caesar." - Julius Caesar
Report Abuse
SirNoobly is not online. SirNoobly
Joined: 01 Oct 2009
Total Posts: 253
23 Sep 2014 12:43 PM
Set the menu to not Visible. In the properties.

I think.
Report Abuse
PlumJar is not online. PlumJar
Joined: 04 Mar 2012
Total Posts: 907
23 Sep 2014 12:55 PM
No





menu = script.Parent.Parent.MenuFrame

function open()
menu.Visible = true
on = true
menu.Profile:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Inventory:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.BuyPoints:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Uniform:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
on = false
end

function close()
on = true
menu.Profile:TweenPosition(UDim2.new(-1,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Inventory:TweenPosition(UDim2.new(1,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.BuyPoints:TweenPosition(UDim2.new(-1,0,0,0),"Out","Bounce",1,true)
wait(0.5)
menu.Uniform:TweenPosition(UDim2.new(1,0,0,0),"Out","Bounce",1,true)
wait(1)
menu.Visible = false
on = false
end

on = false ------this i think

script.Parent.MouseButton1Click:connect(function()
if menu.Visible == false and on == false then
open()
elseif menu.Visible == true and on == false then
close()
end
end)
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Sep 2014 01:01 PM
It's your default for on, I'm sure.
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
23 Sep 2014 01:11 PM
Oh, I forgot to post the on variable

right below menu is this
on = false


"Et tu, Brute? Then fall, Caesar." - Julius Caesar
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Sep 2014 01:13 PM
Default Visible value?
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
23 Sep 2014 01:21 PM
False


"Et tu, Brute? Then fall, Caesar." - Julius Caesar
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
23 Sep 2014 01:23 PM
Wait, it was true.. ugh. Thanks. I'm so stupid, lol


"Et tu, Brute? Then fall, Caesar." - Julius Caesar
Report Abuse
4444vince2 is not online. 4444vince2
Joined: 08 Nov 2008
Total Posts: 4880
23 Sep 2014 01:28 PM
Script has to be a localscript you can only tween in localscripts.
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
23 Sep 2014 01:29 PM
@Vince

Wrong. Wiki is outdated on that part. You can tween in normal scripts.
Try it.


"Et tu, Brute? Then fall, Caesar." - Julius Caesar
Report Abuse
4444vince2 is not online. 4444vince2
Joined: 08 Nov 2008
Total Posts: 4880
23 Sep 2014 01:33 PM
I know but for along time there roblox broke it and I guess they finally fixed it. :P
Gimmie a min i'll clean your code up. :3
Report Abuse
4444vince2 is not online. 4444vince2
Joined: 08 Nov 2008
Total Posts: 4880
23 Sep 2014 01:37 PM
--You may have to change some things I just edited the first code you posted. :P

menu = script.Parent.Parent.MenuFrame

function open()
menu.Visible = true
on = true
for i=1, 4 do
menu.Profile:TweenPosition(UDim2.new(0,0,0,0),"Out","Bounce",1,true)
wait(0.5)
end
on = false
end

function close()
on = true
for i=1, 4 do
menu.Profile:TweenPosition(UDim2.new(-1,0,0,0),"Out","Bounce",1,true)
wait(0.5)
end
wait(0.5)
menu.Visible = false
on = false
end

on = false

script.Parent.MouseButton1Click:connect(function()
if menu.Visible == false and on == false then
open()
elseif menu.Visible == true and on == false then
close()
end
end)
Report Abuse
4444vince2 is not online. 4444vince2
Joined: 08 Nov 2008
Total Posts: 4880
23 Sep 2014 01:39 PM
Ohh.. >_>
Just noticed there all something diff. XD
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
23 Sep 2014 01:47 PM
Derrrrp
Report Abuse
PlumJar is not online. PlumJar
Joined: 04 Mar 2012
Total Posts: 907
24 Sep 2014 08:55 AM
so was i right or what? ;3


Mewo.
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
24 Sep 2014 09:00 AM
@Plum
You weren't right, I already had the on variable defined as false.
The problem was that the frame's visibility was true to begin with, making the scripting requiring you to click twice to make it appear to work the first time.


"Et tu, Brute? Then fall, Caesar." - Julius Caesar
Report Abuse
PlumJar is not online. PlumJar
Joined: 04 Mar 2012
Total Posts: 907
24 Sep 2014 09:02 AM
Oh ok, well im glad you were able to fix your prob.


Mewo.
Report Abuse
DarkheartSkillz is not online. DarkheartSkillz
Joined: 30 Sep 2011
Total Posts: 5125
24 Sep 2014 09:03 AM
Yeah, but if you want, I need help fixing my data store script. :[


"Et tu, Brute? Then fall, Caesar." - Julius Caesar
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