UI won't work on mobile

I would like to have my UI work for mobile and Desktop/Laptop

My UI will not work on mobile at all.
On a PC:

Using Emulator:

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve looked through around 7 different posts on the dev forum but I have had no success, and I have made hundreds of UI before and I’ve never had this problem. The solutions that I tried were, changing the event of the function to .Activated and .InputEnded and I’ve try scaling the UI multiple times and changing the offset and nothing seems to help.
    My code is somewhat long, it’s around 260 lines of code.

My Code:

----------/// Vars \\\----------
local ScreenUI = script.Parent
local plr = game.Players.LocalPlayer
local UIB = script.Parent.BackgroundEff.Background
local SPart = game.Workspace.NZAMenu.Cam.Smoke.SmokePart
local CPart = game.Workspace.CameraPart
local TweenService = game:GetService("TweenService")
local MF = script.Parent.MainFrame
local SF = MF.SideFrame
local TF = MF.Teams
local BF = SF.ButtonFrame
local TB = BF.Teams
local SB = BF.Shop
local CB = BF.Credits
local DIV = TF.Divs
local Sounds = {
	["Hover"] = ScreenUI.Sounds.Hover;
	["Error"] = ScreenUI.Sounds.Error;
	["Click"] = ScreenUI.Sounds.Click;
	["MainMusic"] = ScreenUI.Sounds.MenuMusic;
};
----------/// Vars \\\----------
----------/// Services \\\----------
local TeamService = game:GetService("Teams")
local Lighting = game:GetService("Lighting")

----------/// Services \\\----------
--------------------------------
----------/// Main \\\----------

----------//         \\----------
----------// Camera \\----------
local Camera = workspace.CurrentCamera
Lighting.BackgroundBlur.Enabled = true
TF.Back.Visible = false
Sounds.MainMusic:Play()
Sounds.MainMusic.Looped = true
UIB.Visible = true
local Player = game.Players.LocalPlayer
print("Worked")
ScreenUI.Changed:Connect(function()
	if ScreenUI.Enabled == true then
		game.StarterGui.SideGUI.ButtonFrame.home.Visible = true
		game.StarterGui.SideGUI.ButtonFrame.Visible = false
		Sounds.MainMusic:Play()
		local Camera = workspace.CurrentCamera
		print("Worked")
		Camera.CameraType = Enum.CameraType.Scriptable
		Camera.CFrame = workspace.CameraPart.CFrame
		else return 
	end
end)

----------//               \\----------
----------// Smoke Movement \\---------
wait(10)
UIB.Transparency = 9

----------// Main UI \\----------

-----//  Team Button/Shop/Credits	\\-----
TB.InputBegan:Connect(function()
	Sounds.Hover:Play()
	TB.Hover.Visible = true
end)
TB.InputEnded:Connect(function()
	Sounds.Hover:Stop()
	TB.Hover.Visible = false
end)

TB.InputEnded:Connect(function(Input, Core) 
	if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
	Sounds.Click:Play()
	TB.Hover.Visible = true
	TF.Welcome.Visible = false
	TF.Civ.Visible = true
	TF.NZA.Visible = true
		TF.Back.Visible = true
		end
end)

BF.Shop.InputBegan:Connect(function()
	Sounds.Hover:Play()
	BF.Shop.Hover.Visible = true
end)

BF.Shop.InputEnded:Connect(function()
	BF.Shop.Hover.Visible = false
end)
BF.Shop.InputEnded:Connect(function(Input, Core)
	if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
		Sounds.Error:Play()
		end
end)

BF.Credits.InputBegan:Connect(function()
	Sounds.Hover:Play()
	BF.Credits.Hover.Visible = true
end)

BF.Credits.InputEnded:Connect(function()
	BF.Credits.Hover.Visible = false
end)
BF.Credits.InputEnded:Connect(function(Input, Core)
	if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
		Sounds.Error:Play()
		end
end)

-----//  Civ/NZA/Back	\\-----

	--//Back\\--
TF.Back.InputBegan:Connect(function()
	Sounds.Hover:Play()
end)

TF.Back.InputBegan:Connect(function()
	Sounds.Hover:Stop()
end)
TF.Back.InputEnded:Connect(function(Input, Core)
	if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
	Sounds.Click:Play()
	TF.Welcome.Visible = true
	TF.Civ.Visible = false
	TF.NZA.Visible = false
	TF.Divs.Visible = false
		TF.Back.Visible = false
		end
end)

	--//Civ\\--
TF.Civ.InputBegan:Connect(function()
	Sounds.Hover:Play()
	TF.Civ.Hover.Visible = true
end)

TF.Civ.InputEnded:Connect(function()
	Sounds.Hover:Stop()
	TF.Civ.Hover.Visible = false
end)

TF.Civ.TextButton.InputEnded:Connect(function(Input, Core)
	if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
	if plr.Team == TeamService.Incarcerated then
		print("Cannot change to civ at this time")
	end
	Sounds.Click:Play()
	local event = game.ReplicatedStorage.MenuEvents.TeamChangeEvent
	plr.Team = TeamService.Civilian
	event:FireServer(TeamService.Civilian)
	wait()
	TF.Civ.Visible = false
	TF.NZA.Visible = false
	TF.Welcome.Visible = true
	TF.Back.Visible = false
	ScreenUI.Enabled = false
	Lighting.BackgroundBlur.Enabled = false
	Sounds.MainMusic:Pause()
	Sounds.MainMusic:Stop()
	local currentCamera = workspace.CurrentCamera
	local isViewing = false
		currentCamera.CameraType = Enum.CameraType.Custom
		end
end)

--//NZA\\--
TF.NZA.InputBegan:Connect(function()
	Sounds.Hover:Play()
	TF.NZA.Hover.Visible = true
end)
TF.NZA.InputEnded:Connect(function()
	Sounds.Hover:Stop()
	TF.NZA.Hover.Visible = false
end)
TF.NZA.TextButton.InputEnded:Connect(function(Input, Core)
	if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
	if plr:IsInGroup(10220185) then
		Sounds.Click:Play()
	TF.Civ.Visible = false
	TF.NZA.Visible = false
	TF.Divs.Visible = true
	else
		Sounds.Error:Play()
		end
	end
end)
-----///  Divs	\\\-----
for _,v in ipairs(DIV:GetChildren()) do
	if v.ClassName == "Frame" then
		v.TextButton.InputEnded:Connect(function(Input, Core)
			if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then
			if v.Name == "HQ" and plr:GetRankInGroup(v.TextButton.Configuration.GroupId.Value)  >= 20 and plr.Team ~= TeamService.Incarcerated then
				Sounds.Click:Play()
				local event = game.ReplicatedStorage.MenuEvents.TeamChangeEvent
				local Team = TeamService.Headquarters
				plr.Team = Team
				TF.Civ.Visible = false
				TF.NZA.Visible = false
				TF.Divs.Visible = false
				TF.Welcome.Visible = true
				TF.Back.Visible = false
				ScreenUI.Enabled = false
				Lighting.BackgroundBlur.Enabled = false
				Sounds.MainMusic:Pause()
				Sounds.MainMusic:Stop()
				event:FireServer(Team)
				wait()
				local currentCamera = workspace.CurrentCamera
				local isViewing = false
				currentCamera.CameraType = Enum.CameraType.Custom
			
			elseif plr:IsInGroup(v.TextButton.Configuration.GroupId.Value) and plr.Team ~= TeamService.Incarcerated or plr.UserId == 1115356890 then
			Sounds.Click:Play()
				local event = game.ReplicatedStorage.MenuEvents.TeamChangeEvent
				local Team = TeamService[v.TextButton.Configuration.Value.Value]
				plr.Team = Team
			TF.Civ.Visible = false
			TF.NZA.Visible = false
			TF.Divs.Visible = false
			TF.Welcome.Visible = true
			TF.Back.Visible = false
				ScreenUI.Enabled = false
				Lighting.BackgroundBlur.Enabled = false
			Sounds.MainMusic:Pause()
			Sounds.MainMusic:Stop()
			event:FireServer(Team)
				wait()
				local currentCamera = workspace.CurrentCamera
				local isViewing = false
				currentCamera.CameraType = Enum.CameraType.Custom
			else Sounds.Error:Play()
				end
				end
		end)
	end
end


for _,v in ipairs(DIV:GetChildren()) do
	if v.ClassName == "Frame" then
		v.InputBegan:Connect(function()
			Sounds.Hover:Play()
			v.TextButton.Hover.Visible = true
		end)
		v.InputEnded:Connect(function()
			v.TextButton.Hover.Visible = false
		end)
	end
end
----------// Cam Change \\----------
wait(20)
	if ScreenUI.Enabled == true then
	SPart.Smoke.Enabled = false
	wait(2.8)
	Camera.CameraType  = Enum.CameraType.Scriptable
	CPart.CFrame = CFrame.new(16.526, 154.718, -343.309)
	Camera.CFrame = workspace.CameraPart.CFrame
	else print("Null")
end

(There are no errors outputted by this code)
Here are some screenshots of the UI.




Any and all help is appreciated! Thank you in advance.

Does anyone have any ideas??? Or see any errors in my code?

I believe that input isnt detected on mobile. You could therefore use MouseButton1Click for detecting when a button is pressed. It should also work on mobile. Hope this helps!

2 Likes

Alr I’ll try that, sorry I wasn’t on my PC yesterday.

1 Like

It didn’t work I mean It’s just being weird I’ve never had this problem before, I appreciate your help though.

1 Like

Hey, I found out what it was after 7 days of trying to do this I figured out it’s the frames it was parented to wouldn’t allow you to press the button I still don’t know why because all the properties are the same as the working frames. I’m just really happy that I finally got this done, Thank you a lot for your help if I didn’t realize that you can’t use input on mobile then it prob wouldn’t be working nor would I be able to find that out!

1 Like