Strange effect with button script

Very confused why this strange effect occurs with my button script:

-- Variables --

local soundHover = game:GetService("SoundService"):WaitForChild("SoundEffects"):WaitForChild("Clicks"):WaitForChild("UI Hover")
local soundClick = game:GetService("SoundService"):WaitForChild("SoundEffects"):WaitForChild("Clicks"):WaitForChild("ButtonClick")
local btn = script.Parent
local isHovering = false

-- Functions --

  -- ClickFeedback --

btn.MouseButton1Down:Connect(function()

	btn:TweenSize(UDim2.new(0, 154,0, 49), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

btn.MouseButton1Up:Connect(function()

	if not isHovering then
		btn:TweenSize(UDim2.new(0, 164,0, 54), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
	else
		btn:TweenSize(UDim2.new(0, 174, 59, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
	end
end)
  -- HoverFeedback --

btn.MouseEnter:Connect(function()
	isHovering = true
	soundHover:Play()
	btn:TweenSize(UDim2.new(0, 174,59, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

btn.MouseLeave:Connect(function()
	isHovering = false
	soundHover:Play()
	btn:TweenSize(UDim2.new(0, 164,0, 54), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)

video link here.

You need to flip the 59 and 0 lol. That’s it.

btn:TweenSize(UDim2.new(0, 174,0, 59), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)

1 Like

You are setting the tween Size to an absurd amount of 59 times the Y size of your screen
Set it back to offset then you can use this plugin to convert them to scale and fit on all devices (DevForum post: [Plugin] AutoScale Lite for GUIs - Scale your UI)

2 Likes

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