Unable to tween TextSize

local ogSize = script.Parent.Size
local duration = 0.1
local button = script.Parent
local text = button.Text
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut)
local tween1 = TweenService:Create(button.Text ,tweenInfo,{TextSize = 50})

Also getting an error:
00:09:56.358 Unable to cast value to Object - Client - LocalScript:7
I have checked other topics but none have proved successful so far.

2 Likes

you are tweening the text of the button, not a property of a button
on line 7 (last line) you set the object of the tween to the text of the button
correct code:

local ogSize = script.Parent.Size
local duration = 0.1
local button = script.Parent
local text = button.Text
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut)
local tween1 = TweenService:Create(button,tweenInfo,{TextSize = 50})

It results in no error now but does not change the text size.


(I haven’t added a tween to put the texts size back so it should remain at 50.

interesting, i would think that should work. i’m recreating it in roblox studio right now

also W ui images

2 Likes

I needed some placeholders lmao.
Heres the full code if that might help you:

local ogSize = script.Parent.Size
local duration = 0.1
local button = script.Parent
local text = button.Text
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Bounce, Enum.EasingDirection.InOut)
local tween1 = TweenService:Create(button ,tweenInfo,{TextSize = 50})


script.Parent.MouseEnter:Connect(function()
	button:TweenSize(ogSize + UDim2.new(0.1,0.1,0.1,0.1), Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce, duration)
	tween1:Play()
end)

script.Parent.MouseLeave:Connect(function()
	script.Parent:TweenSize(ogSize, Enum.EasingDirection.InOut, Enum.EasingStyle.Bounce, duration)
end)

it works for me…
image

1 Like

I do have a lot of things inside the TextButton,
Might that affect it?
image

1 Like

i added all of those things, and it still works perfectly fine. even if you did not have those in, it would make no difference except for looks

edit: if you just want the text to scale with the button then just turn on textScaled and add a UIpadding to the button so the text does not go up to the edge

I just realized a problem when taking a video for you.
It appears I can’t even change the size now when I run it, which is irregular.

Wait nvm.


interesting

1 Like

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