Gui buttons not working well

In my game, I made a menu (Screen Gui), there are buttons in it. When I click those buttons on pc, they work perfectly well. But when I play on a mobile device (Ipad, Phone), and i try to click the buttons, they do not work (nothing happens when i press them).
There isn’t any errors in the script thats in the button, so i don’t know what the problem is, if you could help, i appreciate it.

If you need more info, leave a reply and ill provide it for you.

thank you :smile:

1 Like

We need to be able to see your code to understand where we need to help you. For example, are you using the MouseButton1Click, TouchTap, Activated events? Please always include any associated code in the initial post.

Im using MouseButton1Click in my buttons.

local button = script.Parent
local ScrollingFrame = script.Parent.Parent.Parent.TeamChooseFrame
local MainMenu = script.Parent.Parent.Parent.MainMenu
local Frame  = script.Parent.Parent.Parent.MainMenu.Offset.Frame

button.MouseButton1Click:Connect(function()
	ScrollingFrame:TweenPosition(UDim2.new(0.5, -250,1.16, -200), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
	wait(0.9)
	ScrollingFrame.Visible = false
	MainMenu.Visible = true
	Frame:TweenPosition(UDim2.new(0, 0,0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad)


end)

That is most likely the reason why. On mobile, there is no mouse input, therefore MouseButton1Click in unusable. For mobile users, the equivalent would be the TouchTap event.

Put this script in the ServerScriptService

--Services
local players = game:GetService("Players")
local gyroService = game:GetService("UserInputService")

local function onJoin(plr)
	plr.CharacterAdded:Connect(function()
		local onMobile = Instance.new("BoolValue", plr.Character)
		onMobile.Name = "onMobile"
		if gyroService.GyroscopeEnabled then
			onMobile = true
		else
			onMobile = false
		end	
	end)
end

players.PlayerAdded:Connect(onJoin)

Your original posted script, but updated:

local player = game.Players.LocalPlayer
local button = script.Parent
local ScrollingFrame = script.Parent.Parent.Parent.TeamChooseFrame
local MainMenu = script.Parent.Parent.Parent.MainMenu
local Frame  = script.Parent.Parent.Parent.MainMenu.Offset.Frame
local onMobile

player.CharacterAdded:Connect(function()
	if player.Character.onMobile then
		onMobile = true
	else
		onMobile = false
	end
	
	if onMobile then
		button.TouchTap:Connect(function()
			ScrollingFrame:TweenPosition(UDim2.new(0.5, -250,1.16, -200), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
			wait(0.9)
			ScrollingFrame.Visible = false
			MainMenu.Visible = true
			Frame:TweenPosition(UDim2.new(0, 0,0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
		end)
	else
		button.MouseButton1Click:Connect(function()
			ScrollingFrame:TweenPosition(UDim2.new(0.5, -250,1.16, -200), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
			wait(0.9)
			ScrollingFrame.Visible = false
			MainMenu.Visible = true
			Frame:TweenPosition(UDim2.new(0, 0,0, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quad)
		end)
	end
end)

Thank you so much, beforre you sent the script, i found that the glitch was because of the Zindex on the button :bowing_man: :sweat:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.