Tweening only the X axis of a GUI position

Hey so, I am making a simple notifs system to alert of player joins, and leaves, I have a invisible frame right now with a UIListLayout, but I am oblivious as how I can tween my notification onto the screen, with the UIListLayout considering it handles positions and I’m counting on that it probably bug out. How’d I do this properly?

As well as this, due to the UIListLayout handling the Z and Y axis positions, i’d like to ask how I can tween specifically the X axis to slide on and off the screen. If my question is confusing, please say so! Thanks

1 Like

If I can understand your question correctly, what you would do is just use the TweenPosition function of GuiObjects to tween the Gui to a specific area, if you want it to only move in the x axis, then you can just take form this example

Frame:TweenPosition(UDim2.new(0.5,0,Frame.Position.Y.Scale,0))

Where Frame is the Object you want to move

Here it will move Frame to 0.5 in the Scale of the X position and ignore the Y axis since we told it that we want to tween it to the Y scale of the Frame, which it already is, meaning it just tweens on one axis. I believe this is how you wanted it from what I could read. Also, I’m not understanding one thing

GuiObjects are 2 dimensional, X and Y, where are you getting the Z from or did you mean to write X?

1 Like

Z was a mistake, ty for the answer!

1 Like

My other question to be clear was, once I DO tween it onto the screen, how do I determine WHICH x position to tween to, considering the UIListLayout handles that?

1 Like

As in, where the Frame tweens if you want to show it? What you could do is move the Frame in Studio to where you want it to appear when open and save the X axis, and for when it goes out, just put a value for the X axis to be under 0 to over 1, depending if the Gui is on the left or the right.

1 Like

I want to slide my notification from the left of the screen, all I need to know, is how I can predict what Y location the UIListLayout will place the frame at, I know what X location to tween it to, just not the Y location atm

1 Like

What do you mean by predicting the Y location?

1 Like

Okay so, imagine there are 2 players in a server. I want a notification that tweens onto the screen if a player leaves, so if they leave at the same time (the purpose of the uilistlayout), how can I tween it onto the screen correctly?

1 Like

Before I answer anything, how does the UI in question look like and the Hierachy? The way I have in my head is a bit hard to explain, so I’ll try with an Example

You have a UI for alerts, and the distance from when it’s hidden to when your tween finishes is 0.2 in the X scale. So if multiple palyers leave before the alert UI is gone, make a new UI and move all of them by 0.2, and when it has to disappear, move them back by 0.2.

Although what I probably said is still confusing and may not work if your UI is set up differently, how does the Alert UI work? Does it clone/create a new Frame with the name of the person who left and what not?

1 Like

btw this script is not necessarily working, it doesn’t tween, it just shows up

1 Like

The reason why it could just be showing up is that the goal position is the same as where the frame in ReplicatedStoraage is located. Another thing I would do is change the false in the TweenPosition to true, this will make it so other scripts can override the current Tween if needed, setting it to false prevents other scripts from overriding the current Tween

1 Like

In replicatedstorage, the notification positions are off the screen, so they are different from the goal position.

1 Like

Hmm, I’m not sure what it could be, the code looks like it should work. Did you try it in a local script in StarterGui or anywhere a local script can be placed before?

1 Like

Yeah, I have. Only30Characters

1 Like

Hey, I made a script which moves only X axis of frame position. (If you want other values on X axis, then change only first two digits as they move your GUI left/right. Third and fourth digits are for Y axis, so they move your GUI up/down)

local frame = script.Parent -- Your frame to tween
frame:TweenPosition(
	frame.Position + UDim2.new(0,50,0,0), -- Goal (in this case moved right by 50 on X Axis)
	"Out", -- EasingDirection
	"Quad", -- EasingStyle
	1 -- Time
)

If you have any questions feel free to message me here or for private messages

1 Like