Recently I’ve been working on a gui system and whenever I tween a gui to make it smaller it goes in one direction a tiny bit. the thing is I want to keep it in place instead of moving that little bit. does anyone know a specific way to code it so it stays where I want it? thanks.
as you can see when the guis shrink they are locked to the top left of the frame.
(don’t worry about they constantly shrinking, I just want to know how to keep them centered when shrinking.)
Yeah when creating a tween for a GUI element, both the ‘Size’ and ‘Position’ properties expect values of type UDim2 , notVector2
the AnchorPoint property of a GUI element is a Vector2 , which is the " normalized " position within the element where the anchor is set, but it cant be used as the ‘Position’ in a tween because they are different types
anchorpoint is used to determine the pivot point of the UI element while the Position determines the actual position of the element in the parent container. they work together to place the element, but they are not interchangeable. personally i would fix it like this:
Set the AnchorPoint of the OtherGui element separately and outside of the tween, if you need to change it
Create the tween with the UDim2 value for the Position
You do not use code for this (atleast what I think, never used anchorpoints before). But I think I know how it goes.
In this image you can see the default anchorpoint is on the upper left corner (0,0) so when you resize the GUI it will resize from the left upper corner.
But if you put the anchor point (0.5,0.5) the anchor point will be in the middle and the scale will resize in the center
I suck at explaining, maybe the images will help. lmk if you need any more help.
Edit: make every anchorpoint on the UI elements that you’re trying to resize to (0.5,0.5)
Thanks I had to change one line in the code along with this but it seemed like a easier and faster fix than rewriting the code to accommodate anchor points. appreciate both of the responses.