MouseEnter and Leave Issue

Hi!

I have 2 scripts that do the following:

The first script uses MouseEnter and MouseLeave to Tween a GUI to be bigger or smaller.

The second script uses MouseButton1Click to detect when the textbutton is clicked to reset the GUI to it’s original position.

The main issue is while my code theoretically works, it simply doesn’t on mobile

Here is the second script:

script.Parent.MouseButton1Click:Connect(function()
	
	script.Parent.Parent.Parent.PlayButton.Size = UDim2.new(0.245, 0,0.105, 0)
	script.Parent.Parent.Parent.PlayButton.Position = UDim2.new(0.378, 0,0.679, 0)
	script.Parent.Parent.Position = UDim2.new(0.147, 0,0.695, 0)
	script.Parent.Parent.Size = UDim2.new(0.21, 0,0.09, 0)	
	
end)

Any help is appreciated :slight_smile:

1 Like

What part of it does not work on mobile?

.MouseButton1Click doesn’t work on mobile. Use .Activated.

1 Like

I tried .Activated and it still isn’t working.

Well it doesn’t work on all devices but it’s most frequently happening on mobile.

Essentially, I’m using MouseEnter and MouseLeave on a textbutton so that when your mouse hovers over the button, the GUI becomes bigger

However, when you click the button I want the GUI to go back to its original size and position

It’s frequently not working on mobile but it’s not working much across all devices

Try using .InputBegan and checking if the input type is the one you want.

I’m a bit confused on what you mean by this…
Could you explain a bit further?

*I’m aware of what InputBegan is.
Just not sure how it would help in this scenario

all of the sudden I’m having trouble remembering things

gui.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        print("do whatever here")
    end
end)

I haven’t tested it, frankly, I’ve never used this event before.

1 Like

still not working unfortunately
:frowning:

I don’t think this has anything to do with detecting whether or not the GUI is being clicked or not

I think you’re right. You did say that on all devices it wasn’t working consistently.

It most likely has something to do with the MouseEnter and MouseLeave script and something contradicting there

It may be consistently happening on mobile because both scripts would fire at the same time but I’m not really sure

Could you send both scripts right now? I’m doing something else right now and multitasking.

Script 1:

script.Parent.MouseButton1Click:Connect(function()
	
	script.Parent.Parent.Parent.PlayButton.Size = UDim2.new(0.245, 0,0.105, 0)
	script.Parent.Parent.Parent.PlayButton.Position = UDim2.new(0.378, 0,0.679, 0)
	script.Parent.Parent.Position = UDim2.new(0.147, 0,0.695, 0)
	script.Parent.Parent.Size = UDim2.new(0.21, 0,0.09, 0)	
	
end)

Script 2:

script.Parent.TextButton.MouseEnter:Connect(function()
		
		game:GetService("SoundService").UiHover:Play()

		ctt.Parent.Visible = true
		ctt.Text = "Extra information, statistics and credits"

		script.Parent.Parent.ActiveHover.Value = "Extra"

		wait(0.01)

		if script.Parent.Parent.ActiveHover.Value ~= "Extra" then

		else
			ex:TweenSizeAndPosition(
				UDim2.new(0.273, 0,0.117, 0),
				UDim2.new(0.122, 0,0.667, 0),
				"Out",
				"Quad",
				0.1,
				true
			)

			play:TweenSizeAndPosition(
				UDim2.new(0.207, 0,0.089, 0),
				UDim2.new(0.416, 0,0.695, 0),
				"Out",
				"Quad",
				0.1,
				true
			)
		end
	
end)

script.Parent.TextButton.MouseLeave:Connect(function()
	ctt.Parent.Visible = false
	
	script.Parent.Parent.ActiveHover.Value = ""
	
	if script.Parent.Parent.ActiveHover.Value == "Extra" then
		
	else
		ex:TweenSizeAndPosition(
			UDim2.new(0.21, 0,0.09, 0),
			UDim2.new(0.147, 0,0.695, 0),
			"Out",
			"Quad",
			0.1,
			true
		)

		play:TweenSizeAndPosition(
			UDim2.new(0.245, 0,0.105, 0),
			UDim2.new(0.378, 0,0.679, 0),
			"Out",
			"Quad",
			0.1,
			true
		)

	end
end)

using MouseButton1Down instead of that should work