Main Menu Play Button bugs

Hi, I am new to programming on Roblox. I am having an issue where my play button doesn’t remove the entire main menu and reset the camera back to default. It will grateful if anyone is able to help me with this issue:

local menu = game.StarterGui.MenuGui
local camera = game.Workspace.CameraRig
local backgroundmusic = game.StarterGui.Music
local CameraRigScript = game.StarterGui.CameraRigScript
local StarterCam = game.StarterPlayer.StarterCharacterScripts.LocalScript
local GameMenu = game.Workspace.MainMenu
local Glasses = game.StarterGui.Glass
local PAKMenu = game.StarterGui.PAKTCGui
local logo = game.StarterGui.StudioLogo
local camFOV = game.StarterPlayer.StarterCharacterScripts.CamFOV

script.Parent.MouseButton1Click:Connect(function()
	menu:Destroy()
	print("MainMenu destroyed")
	camera:Destroy()
	print("CameraRig destroyed")
	backgroundmusic:Destroy()
	print("Music destroyed")
	CameraRigScript:Destroy()
	print("Camera Rig script destroyed")
	StarterCam:Destroy()
	print("StarterCam destroyed")
	GameMenu:Destroy()
	print("GameMenu Destroyed")
	Glasses:Destroy()
	print("Glasses destroyed")
	PAKMenu:Destroy()
	print("PAKMenu destroyed")
	logo:Destroy()
	print("Logo destroyed")
	camFOV:Destroy()
	print("CamFOV destroyed")
end)

To anyone that wants to see the test, here is the link.

External Media

Hey,

Im going to recommend trying to look at Roblox’s Documentation. Specifically, PlayerGui | Documentation - Roblox Creator Hub.

StarterGui, of which you are using to get multiple ScreenGuis and more, is better utilzied to manage other items. Please look at StarterGui | Documentation - Roblox Creator Hub

PlayerGui is created when then Player is added to the game.

you are accessing all the starter stuff (like what the guy above said), so youre basically deleting presets

also, it is pretty useless to define a variable you are only going to use once

Thanks for the GUI solution but another problem is the camera will not reset back to the player even when I click the playButton. Do you have any advice for that?

You will reset the players camera back similar to the same way you set it to the CameraRig.

Change the CameraType to Custom and CameraSubject set to the Player character PrimaryPart.

Workspace | Documentation - Roblox Creator Hub
Customize the camera | Documentation - Roblox Creator Hub

Just another question if you don’t mind but is there a way to also remove the mouse tracking camera script and also make the player be able to walk again? Right now that I have set the camera back to player and the playergui is turn off but the camera keep moving back to the same rotation when I try to rotate my player camera to different angle and the player won’t move too.

In a private script simply go ahead and address your parent object, I’d assume it’d be “Menu” so I’ll use it in the example below:

menu.Visible = false
This makes it invisible. There really is no reason to destory your GUIs for nothing.

Isn’t it something to do with the current camera not taking the players camera back? Is there another script for this??