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