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

How to get the old GUI size to tween, to avoid warps in size when minimizing?

Asked by 4 years ago

I am trying to make a GUI where it loads, and then shapes to a larger GUI, that works. However, I cannot get it to read its own current size to make sure that the frames maintain the original shape. Here's my code that isn't working:

local open = true
script.Parent.MouseButton1Click:Connect(function()
    if open == true then --closing function
        local Frame = game.Players.LocalPlayer.PlayerGui.Exoteric.MainTitleFrame
        local Frame2 = game.Players.LocalPlayer.PlayerGui.Exoteric.Main
        local size1 = Frame.Size
        local size2 = Frame2.Size
        local s1 = size1
        local s2 = size2
        Frame2:TweenSizeAndPosition(UDim2.new(s1), UDim2.new(0.3, 0,0.953, 0))
        Frame:TweenSizeAndPosition(UDim2.new(s2), UDim2.new(0.3, 0,0.953, 0))
        open = false
        script.Parent.Text = "?"
    elseif open == false then
        local Frame = game.Players.LocalPlayer.PlayerGui.Exoteric.MainTitleFrame
        local Frame2 = game.Players.LocalPlayer.PlayerGui.Exoteric.Main
        local size1 = Frame.Size
        local size2 = Frame2.Size
        local s1 = size1
        local s2 = size1
        Frame2:TweenSizeAndPosition(UDim2.new(s2), UDim2.new(0.3, 0,0.307, 0))
        Frame:TweenSizeAndPosition(UDim2.new(s1), UDim2.new(0.3, 0,0.307, 0))
        open = true
        script.Parent.Text = "-"
    end
end)

Answer this question