Game Menu not working on Mobile

I am working on a game and it has a main menu that is in workspace. It creates a new Camera instance and sets workspace.CurrentCamera to the new Camera, while storing the old camera for scripts that run before the main menu.

After you press play to play the game, it’ll destroy the new camera and return the old camera.
This works fine on PC/Computer, however, when I am playing on my mobile device, the menu is not visible and a black screen is there.
I’ve tried changing the visibility of the Frame but it is not working.

PC/Computer:


Mobile:

Code:
(The only two things responsible for the blackscreen are MainGui.Background and MainGui.Cover, which are changed in the singleplayer code. I know its the background because you can still hear the door opening.)

-- Main Menu Setup Code
MainGui.MainFrame.Visible = true
	MainMenu.Visible = false
	
	local ShellsFrame = MainGui.MainFrame.Shells
	if ShellsFrame:FindFirstChild("Camera") then
		ShellsFrame.Camera:Destroy()
	end
	
	local Camera = Instance.new("Camera")
	Camera.Name = "ShellCam"
	Camera.CFrame = ShellsFrame.menushells.RootPart.CFrame
	Camera.FieldOfView = 10
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.Parent = ShellsFrame
	MainGui.MainFrame.ShellsViewport.Visible = true
	MainGui.Background.Visible = false
	
	MainMenu.Visible = true
	
	TweenService:Create(MainGui.Cover,
		TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{BackgroundTransparency = 1}
	):Play()
-- Camera Changer & Animator
Shells.Changed:Connect(function(property)
	if property ~= "Visible" then return end
	if Shells.Visible and wasVisible then
		return
	end
	if Shells.Visible == false and wasVisible then
		wasVisible = false
		ShellsObj.Parent = Shells.Parent
		game.ReplicatedStorage.ClientStorage.Camera.Parent = workspace
		workspace.CurrentCamera = workspace.Camera
		MainGui.Background.BackgroundTransparency = 0
		MainGui.Background.Visible = false
		return
	end
	if Shells.Visible and wasVisible == false then
		ShellsObj.Parent = workspace
		local Camera = ShellsObj:WaitForChild("ShellCam")
		workspace.CurrentCamera.Parent = game.ReplicatedStorage.ClientStorage
		workspace.CurrentCamera = Camera
		MainGui.Background.BackgroundTransparency = 1
		MainGui.Background.Visible = false
		wasVisible = true
		-- (Animation Code Here)
	end
end)
-- Singleplayer Code
MainMenu.Singleplayer.MouseButton1Click:Connect(function()
	SoundService.Sounds["health counter confirmation"]:Play()
	SoundService.Music["music main_gate modded"]:Stop()
	SoundService.Sounds["button_start main"]:Play()
	UserInputService.MouseIconEnabled = false
	MainMenu.Visible = false
	local length = SoundService.Sounds["button_start main"].TimeLength + 0.25
	TweenService:Create(MainGui.Cover,
		TweenInfo.new(length, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{BackgroundTransparency = 0}
	):Play()
	task.wait(length)
	MainGui.MainFrame.ShellsViewport.Visible = false
	
	local starttime = os.clock()
	--StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
	MainGui.Cover.BackgroundTransparency = 1
	SoundService.Music["music main_techno techno"].Volume = 0.3
	SoundService.MusicMain.EqualizerSoundEffect.HighGain = -53.9
	SoundService.MusicMain.EqualizerSoundEffect.LowGain = 5.5
	SoundService.MusicMain.EqualizerSoundEffect.MidGain = -8
	SoundService.MusicMain.EqualizerSoundEffect.Enabled = true
	ReplicatedStorage.ClientStorage.Shotgun:PivotTo(CFrame.new(Vector3.new(-81.634, 19.899, -61.041)) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(90)))
	
	local Map = ReplicatedStorage.Models.Main
	Map.Objects.Door1.Door.ClickDetector.MaxActivationDistance = 0
	-- -98.007, 16.402, -61.522
	Map.Characters.Dealer:PivotTo(CFrame.new(Vector3.new(-98.007, 16.402, -61.122)) * CFrame.Angles(0, math.rad(-90), 0))
	Map.Items.Shotgun:Destroy()
	Map.Parent = workspace
	task.wait(0.05)
	MainScript.cam.CFrame = Map.Nodes.Bathroom.CFrame

	MainGui.Background.Visible = true
	MainGui.Cover.BackgroundTransparency = 1
	
	if Settings.Settings.VirtualCursor then
		require(script.VirtualCursor)()
	end
	if Settings.Settings.Shaders then
		require(script.Shaders)()
	end
	
	MusicManager.LoadTrack_FadeIn()
	TweenService:Create(MainGui.Background,
		TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{BackgroundTransparency = 1}
	):Play()
	SoundService.Sounds["ambience_fluorescent light"]:Play()
	print(string.format("It took %.2f seconds to load the Main Game", os.clock() - starttime))
	task.wait(4)
	local Difficulty = MainGui.Difficulty
	Difficulty.TextTransparency = 1
	Difficulty.Text = "AI Difficulty: "..Settings.Settings.SingleAiDifficulty.Table[Settings.Settings.SingleAiDifficulty.Current]
	Difficulty.Visible = true
	TweenService:Create(Difficulty,
		TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{TextTransparency = 0}
	):Play()
	task.wait(2)
	CursorManager.SetCursor(true, true)
	Map.Objects.Door1.Door.ClickDetector.MaxActivationDistance = 1000
	Map.Objects.Vitamins.ClickDetector.MaxActivationDistance = 1000
	if UserInputService.MouseEnabled then
		task.wait(1)
		TweenService:Create(MainGui.MouseInteract,
			TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In),
			{ImageTransparency = 0}
		):Play()
		task.wait(1)
		task.wait(3)
		TweenService:Create(MainGui.MouseInteract,
			TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.In),
			{ImageTransparency = 1}
		):Play()
	end
end)

No errors appear in the console of the mobile version so I don’t know why the device change causes it to break itself.

2 Likes

Is this the issue?

By the way, instead of doing:

local length = 3
TweenService:Create(something, TweenInfo.new(length), somethingElse):Play()
task.wait(length)

You can do this, which would be more accurate:

local tween = TweenService:Create(something)
tween:Play()
tween.Completed:Wait()
1 Like

No, the tween for the background comes before that.

I knew there was probably a better way to do that, thank you.

1 Like

You should try “finding” the Shells first. If you can’t find them, that means they’re not loading for some reason. If you can find them, that means the camera isn’t being set for some reason. Should help narrow down the search

Are there any errors on the client code?

In the post, it says there are no errors or anything in the console.

1 Like

The main menu code only fires after game.Loaded has been sent. I have used print statements to confirm that the camera is being changed and set.

Then go try to find the Shells in Explorer. Go check if game.Loaded is giving the expected output as well

game.Loaded is checked wayyy before that. You wouldn’t even see the buttons. Also, this might be a stupid question, but how will I go into explorer while the game is running on my phone?

You can type commands in the console on the server and check if your player has a certain GUI. You can also test devices in studio, which would be easier.

Also, instead of doing:

UI.Changed:Connect(function(propertyName)
	if propertyName ~= "Visible" then
		return
	end
	
	-- Main code
end)

You can do:

UI:GetPropertyChangedSignal("Visible"):Connect(function()
	-- Main code
end)

You can test mobile in studio.

Test > Device


Like this?

Weird. It works in Studio mobile, but not regular mobile?

1 Like

Try using task.wait(2). Maybe this will solve the issue as from the Roblox Player the game loads much faster.

The game already waits for game.Loaded to fire, but where will I place that?

You might want to place it here.

-- Main Menu Setup Code
task.wait(2)
MainGui.MainFrame.Visible = true
	MainMenu.Visible = false
	
	local ShellsFrame = MainGui.MainFrame.Shells
	if ShellsFrame:FindFirstChild("Camera") then
		ShellsFrame.Camera:Destroy()
	end
	
	local Camera = Instance.new("Camera")
	Camera.Name = "ShellCam"
	Camera.CFrame = ShellsFrame.menushells.RootPart.CFrame
	Camera.FieldOfView = 10
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.Parent = ShellsFrame
	MainGui.MainFrame.ShellsViewport.Visible = true
	MainGui.Background.Visible = false
	
	MainMenu.Visible = true
	
	TweenService:Create(MainGui.Cover,
		TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
		{BackgroundTransparency = 1}
	):Play()
1 Like

Maybe that’s the solution as it works from the roblox studio mobile and not from the normal mobile.

The task.wait(2) did not fix it unfortunately. It is still blank.

After further investigation, it turns out the Lighting of the game is the problem. This game uses the default Roblox Explosion, and because of that, you are able to see the outline on objects when it explodes.

I don’t know why it’s pitch black on mobile but that’s another issue on it’s own.

2 Likes

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