Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.