Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would I make this, "smoother"?

Asked by 8 years ago

I have these two functions which detect when a player hovers over a TextLabel, the size of the text changes accordingly, I was wondering if it was possible to make this more "smoother" rather than instantly changing the size?

local MainFrame = script.Parent:WaitForChild("Main")
local ShopButton = MainFrame:WaitForChild("ShopButton")

function OnMouseHover()
ShopButton.FontSize = "Size28"
end

function OnMouseNotHover()
ShopButton.FontSize = "Size24"
end

ShopButton.MouseEnter:connect(OnMouseHover)
ShopButton.MouseLeave:connect(OnMouseNotHover)

1 answer

Log in to vote
0
Answered by 8 years ago

You can do this with the TextScaled property and the TweenSize or TweenSizeAndPosition method, however this will require the shop button to resize and you may have to use a TextLabel inside of your button to have only the text resize without the entire button.

local MainFrame = script.Parent:WaitForChild("Main")
local ShopButton = MainFrame:WaitForChild("ShopButton")
ShopButton.TextScaled = true -- remove this line if you set the property yourself

function OnMouseHover()
ShopButton:TweenSize(UDim2.new(0,100,0,28),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.3,true)
end

function OnMouseNotHover()
ShopButton:TweenSize(UDim2.new(0,100,0,24),Enum.EasingDirection.InOut,Enum.EasingStyle.Sine,0.3,true)
end

ShopButton.MouseEnter:connect(OnMouseHover)
ShopButton.MouseLeave:connect(OnMouseNotHover)
Ad

Answer this question