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

How can I make this script tween the button's text size?

Asked by 3 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

I have a button and I want its text's size to tween when hovered over but it doesn't work. I guess it can't be used on an element's properties like that, so how would I do this?

local Button = script.Parent

Button.MouseEnter:Connect(function()
    Button.TextSize:TweenSize(UDim2.new(75),"Out","Quad")
end)

3 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

You need to use TweenService.

local TweenService = game:GetService('TweenService')

local Button = script.Parent

Button.MouseEnter:Connect(function()
    TweenService:Create(Button, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {TextSize = 75}):Play()
end)

Button.MouseLeave:Connect(function()
    TweenService:Create(Button, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {TextSize = 64}):Play()
end)

Hope this help, to more questions put bellow on commentaries.

Ad
Log in to vote
1
Answered by 3 years ago

If im not wrong you should just put in only the number, you don't need the UDim2.new()

0
You're right. TextSize is a number value, not a Udim2 value LeedleLeeRocket 1257 — 3y
Log in to vote
0
Answered by 3 years ago
Button.TextSize:TweenSize(UDim2.new(0, 75),"Out","Quad") -- you was changing offset not size
0
You can't use TweenSize with TextSize because TweenSize is a Method and TextSize is a ValueType. NiniBlackJackQc 1562 — 3y

Answer this question