Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this reposition the GUI correctly?

Asked by
Jephi 42
8 years ago

When I press the TextButton it keeps printing out "opened" and "closed"

It also only allows me to open it, and the text of the text button does not change either.

01local button = script.Parent --  the text button you have to press to reposition the frame
02local frame = script.Parent.Parent -- the frame that I wish to move
03local isopen = false
04repeat wait() until button
05 
06button.MouseButton1Down:connect(function()
07    if isopen == false then
08        button.Text = "<" -- make the button text that you press change
09        frame:TweenPosition(UDim2.new(0, 0, .3, 0), 1, "Bounce", .5) -- "opening"
10        isopen = true -- make open == true since the gui has moved positions
11        print("opened")
12    end
13 
14    if isopen == true then
15        button.Text = ">" -- make the button text that you pressed change
16        frame:TweenPosition(UDim2.new(0, -220, .3, 0), 1, "Bounce", .5) -- closing
17        isopen = false -- make open == false because the gui is now out of the screen
18        print("closed")
19    end
20end)

1 answer

Log in to vote
1
Answered by 8 years ago
01local button = script.Parent --  the text button you have to press to reposition the frame
02local frame = script.Parent.Parent -- the frame that I wish to move
03local isopen = false
04repeat wait() until button
05button.MouseButton1Down:connect(function()
06    if isopen == false then
07        button.Text = "<" -- make the button text that you press change
08        frame:TweenPosition(UDim2.new(0, 0, .3, 0), 1, "Bounce", .5) -- "opening"
09        isopen = true -- make open == true since the gui has moved positions
10        print("opened")
11    return
12    end
13    if isopen == true then
14        button.Text = ">" -- make the button text that you pressed change
15        frame:TweenPosition(UDim2.new(0, -220, .3, 0), 1, "Bounce", .5) -- closing
16        isopen = false -- make open == false because the gui is now out of the screen
17        print("closed")
18    return
19    end
20end)

Or

01local button = script.Parent --  the text button you have to press to reposition the frame
02local frame = script.Parent.Parent -- the frame that I wish to move
03local isopen = false
04repeat wait() until button
05button.MouseButton1Down:connect(function()
06    dbounce = false
07    if isopen == false and not dbounce then
08        button.Text = "<" -- make the button text that you press change
09        frame:TweenPosition(UDim2.new(0, 0, .3, 0), 1, "Bounce", .5) -- "opening"
10        isopen = true -- make open == true since the gui has moved positions
11        print("opened")
12    dbounce = true
13    end
14    if isopen == true and not dbounce then
15        button.Text = ">" -- make the button text that you pressed change
View all 21 lines...

Basicly it was closing it, then following on with the code causing it to run the isopen function, i got stuck on this years ago, Its not professional to use dbounce values but if the return doesnt work thats my only way around.

Ad

Answer this question