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

The GUI no longer shrinks automatically when the mouse leaves it. How can i improve it ?

Asked by 3 years ago

I should enlarge the "object" by 20 pixels when the mouse is on it. When the mouse leaves the object, it should return to its original length. The problem now is that if I move the mouse out of the object while it is being enlarged, it stays at this size and no longer shrinks to its original size.

This is my code:

local object = script.Parent

object.MouseEnter:Connect(function(x,y)
    object:TweenSize(UDim2.new(0, 120, 0, 100))
end)

object.MouseLeave:Connect(function(x,y)
    object:TweenSize(UDim2.new(0, 100, 0, 100))
end)

1 answer

Log in to vote
0
Answered by 3 years ago

You forgot toset EasingStyle and Direction. Try this:


local object = script.Parent object.MouseEnter:Connect(function(x,y) object:TweenSize(UDim2.new(0, 120, 0, 100), 'In', 'Linear',1, true) end) object.MouseLeave:Connect(function(x,y) object:TweenSize(UDim2.new(0, 100, 0, 100), 'In', 'Linear', 1, true) end)
Ad

Answer this question