Menu button doesn't work on mobile?

I made a menu for my game, and it has a little icon on the top left corner when pressed, opens a side menu. it works perfectly fine on pc but on mobile it just doesn’t work, I tried detecting if the player is on mobile or pc and disable some functions that I assumed caused the problem, but even after that the problem still persists.

Is there anything I’m doing wrong? Here is my code.

logoButton.MouseButton1Click:Connect(function()
	if sba == true then
		sba = false
		local sbt = tweenService:Create(gui.buttons, TweenInfo.new(0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = UDim2.new(-0.5,0,0,0)})
		local gt = tweenService:Create(gui.UIGradient, TweenInfo.new(0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Offset = Vector2.new(-1,0)})
		gt:Play()
		sbt:Play()
	else
		sba = true
		local sbt = tweenService:Create(gui.buttons, TweenInfo.new(0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Position = UDim2.new(0,0,0,0)})
		local gt = tweenService:Create(gui.UIGradient, TweenInfo.new(0.25, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Offset = Vector2.new(0,0)})
		gt:Play()
		sbt:Play()
	end
end)

if onMobile == false then
	logoButton.MouseEnter:Connect(function()
		if lbd == true then return end
		local hoverTween = tweenService:Create(logoButton, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = UDim2.new(0.15,0,0.3,0); Position = UDim2.new(0.001,0,-0.02,0)})
		hoverTween:Play()
	end)

	logoButton.MouseLeave:Connect(function()
		if lbd == true then return end
		local hoverTween = tweenService:Create(logoButton, TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = UDim2.new(0.13,0,0.26,0); Position = UDim2.new(0.012, 0,0, 0)})
		hoverTween:Play()
	end)

	logoButton.MouseButton1Down:Connect(function()
		lbd = true
		local hoverTween = tweenService:Create(logoButton, TweenInfo.new(0.17, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = UDim2.new(0.13,0,0.26,0); Position = UDim2.new(0.012, 0,0, 0)})
		hoverTween:Play()
	end)

	logoButton.MouseButton1Up:Connect(function()
		lbd = false
		local hoverTween = tweenService:Create(logoButton, TweenInfo.new(0.17, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = UDim2.new(0.15,0,0.3,0); Position = UDim2.new(0.001,0,-0.02,0)})
		hoverTween:Play()
	end)
end
5 Likes

Maybe use .Activated instead of MouseButton1Click in the first function?

2 Likes

Problem still persists, even after I switched it out.

I tried seperating the functions between mobile and PC and the sidebar still doesn’t open only the menu, I was able to open the side bar when the menu was closing though? So it’s not a scripting issue but some other ui issue?

2 Likes

I think you should try to find out, if it is the problem of the input. Try to use print right after the event fires. If it will have no affect, but print out, that means it has nothing to do with the input.

1 Like

Oh wait! I think I got it now!! You weren’t working on GUIs much yet right?
I see you use tweens to adjust the offset position. As a bit more advanced dev, I highly dis recommend you using offset for screen GUIs. Alternatively you should use the Scale propertie. I know a YouTuber, who made a great video about UI. Try watching it here: https://youtu.be/DzCX8xeHxyI?si=gNnmw9mYO9njuv2k

I am only using offsets for uigradient tween, other than that I am not scaling and moving by offset. I tried using print statements to see if it registered an input in the button on mobile, and it did not print anything, and when I opened the menu while it was closing, it registered the input of course. So something is blocking the player from clicking the button when the menu is completely open, I have no clue what it could be.

UPDATE I have a fade effect made with a frame thats over every ui object, it worked fine on pc but on mobile it got in the way
its fixed now with the fade effect gone