Hello. I’m trying to make a hover effect for buttons that scales the button being hovered using the TweenService assistant SPR but the buttons (a frame with objects inside like a full scaled transparent button that activates the button) don’t scale even though it prints when the scale is changed. I assume that with the scale changing and the scale of the GUI objects not changing proportionally, that I’m doing something wrong. I would be very grateful if someone could help me out.
Here’s my script:
local ogScaleX = btn.Size.X.Scale
local ogScaleY = btn.Size.Y.Scale
local ogPosX = btn.Position.X.Scale
local ogPosY = btn.Position.Y.Scale
local ogParentScaleX = btn.Size.X.Scale
local ogParentScaleY = btn.Size.Y.Scale
local ogParentPosX = btn.Position.X.Scale
local ogParentPosY = btn.Position.Y.Scale
if not btn.Parent:IsA("ScreenGui") then
ogParentScaleX = btn.Parent.Size.X.Scale
ogParentScaleY = btn.Parent.Size.Y.Scale
ogParentPosX = btn.Parent.Position.X.Scale
ogParentPosY = btn.Parent.Position.Y.Scale
end
btn.Activated:Connect(function()
btnClick:Play()
end)
btn.MouseEnter:Connect(function()
--[[
btn:TweenSizeAndPosition(
UDim2.new(ogScaleX + btnSizeDiff, 0, ogScaleY + btnSizeDiff, 0),
UDim2.new(ogPosX - btnSizeDiff/2, 0, ogPosY - btnSizeDiff/2, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Sine,
btnSizeTimeIn,
false,
nil
)
]]
if btn.Parent.Parent == buttons then
spr.target(btn.Parent, 0.6, btnSizeTimeIn, {
Size = UDim2.fromScale(ogParentScaleX + btnSizeDiffMainBtns, ogParentScaleY + btnSizeDiffMainBtns),
Position = UDim2.fromScale(ogParentPosX - btnSizeDiffMainBtns/2, ogParentPosY - btnSizeDiffMainBtns/2)
})
else
spr.target(btn, 0.6, btnSizeTimeIn, {
Size = UDim2.fromScale(ogScaleX + btnSizeDiff, ogScaleY + btnSizeDiff),
Position = UDim2.fromScale(ogPosX - btnSizeDiff/2, ogPosY - btnSizeDiff/2)
})
end
if not btnHover.Playing then
btnHover:Play()
end
end)
btn.MouseLeave:Connect(function()
--[[
btn:TweenSizeAndPosition(
UDim2.new(ogScaleX, 0, ogScaleY, 0),
UDim2.new(ogPosX, 0, ogPosY, 0),
Enum.EasingDirection.Out,
Enum.EasingStyle.Sine,
btnSizeTimeOut,
false,
nil
)
]]
if btn.Parent.Parent == buttonsthen
print(btn.Parent.Size)
spr.target(btn.Parent, 0.6, btnSizeTimeOut, {
Size = UDim2.fromScale(ogParentScaleX, ogParentScaleY),
Position = UDim2.fromScale(ogParentPosX, ogParentPosY)
})
else
spr.target(btn, 0.6, btnSizeTimeOut, {
Size = UDim2.fromScale(ogScaleX, ogScaleY),
Position = UDim2.fromScale(ogPosX, ogPosY)
})
end
end)
If anyone requests, I can give additional info. Note that I can’t share what most of my GUI looks like because I don’t want to leak a UI remake that I’ve been working kinda hard on. Thanks. I will not be able to answer any replies until morning (4/8/2023 EST), since I’m pretty tired.