Changing size script doesn't work

I’m currently making a script, where if you hover over it, it magnifies the size; but when your mouse leaves the button you were hovering on, it goes back to it’s default size.

Script:

local button = script.Parent

button.MouseEnter:Connect(function()
	button.Size = UDim2.new(450, 0, 150, 0)
end)
button.MouseLeave:Connect(function()
	button.Size = UDim2.new(419, 0, 133, 0)
end)

But for some reason, when I hover over it, it disappears, and doesn’t come back, no matter what I do:

This is what it looks like before I hover over it:

Screenshot of Explorer:


Note: All the Local Scripts are the magnify scripts I was talking about earlier.

I have not found a solution to this, please help.

1 Like

It appears that the issue is in the values you are using for the UDim2 size. One of the values is likely causing the button to disappear. Try adjusting the values in small increments to see if you can find the issue.

Also, make sure that the button’s Visible property is set to true, and that it is not being hidden by any other parent elements.

local button = script.Parent

local defaultSize = UDim2.new(0.819, 0, 0.217, 0)
local hoverSize = UDim2.new(0.9, 0, 0.267, 0)

button.MouseEnter:Connect(function()
    button.Size = hoverSize
end)

button.MouseLeave:Connect(function()
    button.Size = defaultSize
end)
1 Like

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