GUI Tween not working with MouseEnter/MouseLeave Function

Greetings Reader! :wave:


My goal is to make a repetitive cycle in where if my mouse hovers over my GUI it expands, and when it leaves the GUI it shrinks back to its original size.


The problem I’m having is that I already did the script but, it just won’t work unless I hover, over and over quickly. I want it to immediately work when the mouse leaves the GUI.

GUIProblem

I’ve made 2 LocalScripts located at my ImageButton.
image

My MouseLeave Script:

local frame1 = script.Parent.Parent.Easy
local frame2 = script.Parent.Parent.EasyBackdrop
local frame3 = script.Parent.Parent.EasyBackground

script.Parent.MouseLeave:Connect(function(x, y) 
	frame1:TweenSize(UDim2.new(0.218, 0,0.313, 0), 'In', 'Linear', '1')
	frame2:TweenSize(UDim2.new(0.218, 0,0.316, 0), 'In', 'Linear', '1')
	frame3:TweenSize(UDim2.new(0.218, 0,0.313, 0), 'In', 'Linear', '1')
end)

My MouseEnter Script:

local frame1 = script.Parent.Parent.Easy
local frame2 = script.Parent.Parent.EasyBackdrop
local frame3 = script.Parent.Parent.EasyBackground

script.Parent.MouseEnter:Connect(function(x, y) 
	frame1:TweenSize(UDim2.new(0.233, 0,0.331, 0), 'Out', 'Linear', '1')
	frame2:TweenSize(UDim2.new(0.235, 0,0.357, 0), 'Out', 'Linear', '1')
	frame3:TweenSize(UDim2.new(0.229, 0,0.343, 0), 'Out', 'Linear', '1')
	script.Parent.Pong:Play()
end)

If you can help me out in any way, please do! :happy1:

Instead of using a string for the time parameter, use numbers.

Change the time in these Functions to be 0.1 or something close to it.

1 Like

You need to add the “override” parameter to your parameters, you can check the information here:

https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenSize

2 Likes

This did kinda work, but it still had the same issue. It just occurred less.

I used your override method by setting the MouseLeave scripts to true, and it worked with no problem!

Thank you both for your helpful answers! :happy3:

1 Like