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

How to Tween MouseEnter TextSize?

Asked by
Borrahh 265 Moderation Voter
4 years ago

I get error at the "TextSize = 100" How can I tween the textsize of the GUI Button?

script.Parent.MouseEnter:Connect(function()
    local TweenService = game:GetService("TweenService")
    local tweenInf = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In)
    local Properties = {(TextSize = script.Parent.TextSize = 100)}
    TweenService:Create(script.Parent.TextSize, tweenInf, Properties):Play()
end)

1 answer

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

Sorry for modifying your code so much. You see, "Properties" and "TweenService:Create" has to do with the problem. You don't define what object you're changing, you're just changing what the properties are if you are using TweenService.

For example, if you wanted to change the color of a part, it would just be

local Properties = {Color3.new(0,0,0)} --whatever color you would like it to be

also when you use TweenService:Create, the first one is defining what the parent is. So for the same color example, it would be

TweenService:Create(workspace.Part, tweenInf, Properties)

I respect that you tried, so I whipped up this code for you. Once again, sorry for changing it so much. Just put this in a local script inside of the TextButton.

local TextButton = script.Parent
local TweenService = game:GetService("TweenService")
local TweenInfoA = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In, 0, false, 0)
local Properties = {TextSize = 100}

local Tween = TweenService:Create(TextButton,TweenInfoA,Properties)

TextButton.MouseEnter:Connect(function()
    Tween:Play()
end)

TextButton.MouseLeave:Connect(function()
    Tween:Cancel()
    TextButton.TextSize = 50 --Original Text Button Size
end)
Ad

Answer this question