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

Help! When my TextButton is being tweened with Udim2, it gets so smaller?

Asked by 5 years ago
Edited 5 years ago

This is the script:

local t = game:GetService("TweenService")
local goal = {}
goal.Size = UDim2.new({0, 182},{0, 64})
local m = t:Create(script.Parent, TweenInfo.new(2), goal)
local goal1 = {}
goal1.Size = UDim2.new({0, 188},{0, 50})
local m1 = t:Create(script.Parent, TweenInfo.new(2), goal1)
script.Parent.MouseEnter:Connect(function()
    m:Play()
end)
script.Parent.MouseLeave:Connect(function()
    m:Pause()
    m1:Play()
end)

But it gets so smaller. Please help?

The original size is {0, 188},{0, 50}

0
what is the size of the button originally? chomboghai 2044 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

When you create the UDim2 your doing it wrong. I know in the properties editor it shows the format like ({x,x1},{y,y1}) but in a script it should be like this UDim2.new(x,x1,y,y1) My guess for why its getting smallers is because its taking only the first numbers which you entered as 0. To fix it don't put in the swirly brackets. Do it like this:

local t = game:GetService("TweenService")
local goal = {}
goal.Size = UDim2.new(0, 182,0, 64)
local m = t:Create(script.Parent, TweenInfo.new(2), goal)
local goal1 = {}
goal1.Size = UDim2.new(0, 188,0, 50)
local m1 = t:Create(script.Parent, TweenInfo.new(2), goal1)
script.Parent.MouseEnter:Connect(function()
    m:Play()
end)
script.Parent.MouseLeave:Connect(function()
    m:Pause()
    m1:Play()
end)

I had this problem too before I realized. I feel like a lot of people have this problem and roblox should really change the property editor so people don't make this mistake. Hope this helps.

Ad

Answer this question