Resize UI Element from the opposite side

I am trying to resize a button using TweenService in order to make it look like it is being pushed down when clicked. However, when clicking it, the button is being resized from the bottom side of it.

What happens (wrong):

Wanted result (right):

Script:

local btn = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local TS = game:GetService("TweenService")
local anim_time = 0.1

btn.MouseButton1Down:Connect(function()
	btn.BackgroundColor3 = Color3.fromRGB(134, 213, 138)
	TS:Create(btn.Parent,TweenInfo.new(anim_time,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Size = btn.Parent.Size - UDim2.new(0,0,0.01,0)}):Play()
end)

btn.MouseButton1Up:Connect(function()
	btn.BackgroundColor3 = Color3.fromRGB(144, 229, 148)
TS:Create(btn.Parent,TweenInfo.new(anim_time,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Size = btn.Parent.Size + UDim2.new(0,0,0.01,0)}):Play()

mouse.Button1Up:Connect(function()
     btn.BackgroundColor3 = Color3.fromRGB(144, 229, 148)
     TS:Create(btn.Parent,TweenInfo.new(anim_time,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),{Size = btn.Parent.Size + UDim2.new(0,0,0.01,0)}):Play()
end)

Thanks for your help :slight_smile:

1 Like

if buttons parent is frame then try this:
set frame anchorPoint to 0.5, 1
set frame position at {0.5, 0},{1, 0}

1 Like

It worked exactly as intended! Thanks a lot :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.