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.

local button = script.Parent --  the text button you have to press to reposition the frame
local frame = script.Parent.Parent -- the frame that I wish to move
local isopen = false
repeat wait() until button

button.MouseButton1Down:connect(function()
    if isopen == false then
        button.Text = "<" -- make the button text that you press change
        frame:TweenPosition(UDim2.new(0, 0, .3, 0), 1, "Bounce", .5) -- "opening"
        isopen = true -- make open == true since the gui has moved positions
        print("opened")
    end

    if isopen == true then
        button.Text = ">" -- make the button text that you pressed change
        frame:TweenPosition(UDim2.new(0, -220, .3, 0), 1, "Bounce", .5) -- closing
        isopen = false -- make open == false because the gui is now out of the screen
        print("closed")
    end
end)

1 answer

Log in to vote
1
Answered by 8 years ago

local button = script.Parent -- the text button you have to press to reposition the frame local frame = script.Parent.Parent -- the frame that I wish to move local isopen = false repeat wait() until button button.MouseButton1Down:connect(function() if isopen == false then button.Text = "<" -- make the button text that you press change frame:TweenPosition(UDim2.new(0, 0, .3, 0), 1, "Bounce", .5) -- "opening" isopen = true -- make open == true since the gui has moved positions print("opened") return end if isopen == true then button.Text = ">" -- make the button text that you pressed change frame:TweenPosition(UDim2.new(0, -220, .3, 0), 1, "Bounce", .5) -- closing isopen = false -- make open == false because the gui is now out of the screen print("closed") return end end)

Or

local button = script.Parent --  the text button you have to press to reposition the frame
local frame = script.Parent.Parent -- the frame that I wish to move
local isopen = false
repeat wait() until button
button.MouseButton1Down:connect(function()
    dbounce = false
    if isopen == false and not dbounce then
        button.Text = "<" -- make the button text that you press change
        frame:TweenPosition(UDim2.new(0, 0, .3, 0), 1, "Bounce", .5) -- "opening"
        isopen = true -- make open == true since the gui has moved positions
        print("opened")
    dbounce = true
    end
    if isopen == true and not dbounce then
        button.Text = ">" -- make the button text that you pressed change
        frame:TweenPosition(UDim2.new(0, -220, .3, 0), 1, "Bounce", .5) -- closing
        isopen = false -- make open == false because the gui is now out of the screen
        print("closed")
    dbounce = true
    end
end)


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