Hey! I’m working on a Tween Script for my UI button, where it Tweens whenever the player is hovering over it and/or clicks on the button. I have provided some screenshot of the issue. [EDIT: I didn’t clearly state the issue. I want it to scale in the center of where the actual button is, instead of it scaling to one side only.]
What it looks like normally:
What it looks like when you’re hovering over it:
What it looks like when you click on it:
Here’s the script for it:
local tween = game:GetService("TweenService")
local isHovering = false
local btn = script.Parent
btn.MouseEnter:Connect(function()
isHovering = true
btn:TweenSize(UDim2.new(0.23, 0,0.154, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)
btn.MouseLeave:Connect(function()
isHovering = false
btn:TweenSize(UDim2.new(0.221, 0,0.136, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)
btn.MouseButton1Down:Connect(function()
btn:TweenSize(UDim2.new(0.165, 0,0.086, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end)
btn.MouseButton1Up:Connect(function()
if not isHovering then
btn:TweenSize(UDim2.new(0.221, 0,0.136, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
else
btn:TweenSize(UDim2.new(0.23, 0,0.154, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 0.2, true)
end
end)
Have I done something wrong with the EasingDirection or do I need to change/script something?