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.