Need help with UI Tweening

Looking for someone who is decent on rlua (Roblox Lua) language.

Situation:

I’m currently beginning to experiment UI frameworks in Roblox Studio. I made a LocalScript which consist to open an UI Frame via the usage of a TextButton. The LocalScript includes tweening (easing) styles for it to come on the visual side of the screen smoothly rather than just a simple visibility script that acts as a popup. So, I’ve succeeded into making it come onscreen but I can’t figure out on how to make it go back offscreen with the similar styles.
Here is the original script that acts as “the opening of the UI Frame”:

OpenScript
local Inventory = script.Parent.Inventory
local OpenFrame = script.Parent.OpenFrame

OpenFrame.MouseButton1Up:Connect(function()
    -- Opens Inventory
    
    
    Inventory:TweenPosition(
        UDim2.new(0.207, 0, 0.144, 0), -- End Position
        "Out", -- Easing Direction
        "Quad", -- Easing Style
        1, -- Time in seconds
        false -- Override any other tweens
        )    
end)

And here is the script that is supposed to close it but doesn’t work for some reasons:

CloseScript
local Inventory = script.Parent.Inventory
local CloseButton = script.Parent.CloseButton

CloseButton.MouseButton1Up:Connect(function()
    -- Closes Inventory


    Inventory:TweenPosition(
        UDim2.new(0.207, 0, -0.669, 0), -- End Position
        "Out", -- Easing Direction
        "Quad", -- Easing Style
        1, -- Time in seconds
        false -- Override any other tweens
    )    
end)

As you can see on the second one only the end position is different. I thought I would keep it the same but just change directions to the actual starting ones. If you intend into helping me could you tell me where was my mistake?

3 Likes

I think it could be that you set the override to false so it wont play if a tween is already playing on the GUI, perhaps try setting it to true

1 Like

Hm, still can’t see any results. I’ve tried to set both to true or only 1. By the way here is how the GUI overall looks:
Screenshot 2021-03-18 at 11.55.04

I thought it might be because of the fact that the close button is inside of the inventory frame? Means I need something additional to my script?

1 Like

I think it could be that, maybe for

local CloseButton = script.Parent.CloseButton

Change it to

local CloseButton = script.Parent.Inventory.CloseButton

In your close script

1 Like

Oh yeah it was that! It worked! Thank you so much. So apparently it was because something was missing in the parent of the CloseButton. That makes sense!
Thank you so much haha. Only a word as simple as that. I mean after all that is the process of learning scripting.

3 Likes

It’s honestly fine that simple mistakes go over your head, it’s part of the learning process. If you have anymore issues don’t be afraid to make another post!

2 Likes

Would also be good to get in the habit of having both open / close actions inside a single script and not two! Makes it far easier to navigate your User-Interfaces code!

Oh that sounds efficient. Will consider doing that as of now! Also I’ve seen some of your UI work in the GFXComet server, keep up the great work!

Much appreciated, and it’s far more efficient yes. But mostly organization is the key. Also is just easier for you in the long run.