How to Tween a GUIs size but centered?

Hi everyone, I am trying to add an effect to a button in game that, when you press it, gets a tiny bit smaller and then goes back to its normal size (this is 100% just for effects). The things is, when I resize the button, it gets smaller but to the top left side corner. I would like it to get smaller on itself (centered). This is kinda hard to understand but its the best I can do… It’s as if its center of gravity was on the left top corner whereas I want it on the center. Here is my code.

local function resetStats()
	script.Parent:TweenSize(, 0,0.059, 0), "In", "Linear", 0.1)
	script.Parent:TweenSize(, 0,0.089, 0), "In", "Linear", 0.1)


2 options come to mind

  1. use AnchorPoint and set it to, 0.5)
    this will make it so the position f the ui element is the center.

  2. or you can tween both its position and size at the same time


I tried the second solution although it messed it up completely, probably because I got the math wrong. How do I know what the new position should be?

Try Ocipa’s first solution.


1 Like