I have a frame here:
I also have a function called ButtonFX that is used to animate buttons:
function GUI.ButtonFX(button: GuiButton)
if not button:FindFirstChild("UIAspectRatioConstraint") then
Instance.new("UIAspectRatioConstraint").Parent = button
end
local buttonSize = button.Size
local _TweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
local largeSize = UDim2.new(0, buttonSize.X.Offset + 20, buttonSize.Y.Offset + 20, 0)
button.MouseEnter:Connect(function()
local tween = TweenService:Create(button, _TweenInfo, {Size = largeSize})
tween:Play()
end)
button.MouseLeave:Connect(function()
local tween = TweenService:Create(button, _TweenInfo, {Size = buttonSize})
tween:Play()
end)
button.MouseButton1Down:Connect(function()
local tinySize = UDim2.new(0, buttonSize.X.Offset - 36, 0, buttonSize.Y.Offset - 36)
local tween = TweenService:Create(button, _TweenInfo, {Size = tinySize})
tween:Play()
end)
button.MouseButton1Up:Connect(function()
local tween = TweenService:Create(button, _TweenInfo, {Size = buttonSize})
tween:Play()
wait(0.1)
tween = TweenService:Create(button, _TweenInfo, {Size = largeSize})
tween:Play()
end)
end
Each button has an AnchorPoint of 0.5, 0.5
. When using ButtonFX
on the buttons, they size from the corner rather than the center, which shouldn’t happen (I think). This works fine on GuiButtons that aren’t in a UIListLayout, despite having the same AnchorPoint.
Could someone help me with this?
(I don’t know too much about GUIs, so sorry if the answer is simple)