Turn off the class GUI and re-enable it back when I click play

Hello, I’m facing an issue where I wanted my classGUI to pop up next after I clicked play but it doesn’t work after I entered “game.StarterGui.ClassGui.Enabled = true” this code into the playbutton category. It was supposed to be disabled in the beginning because the main menu is playing. Here is the code for the playbutton.

local Players = game:GetService("Players")

local class = game.StarterGui.ClassGui.Main
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local cam = workspace.CurrentCamera
local Controls = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")):GetControls()
local UserInputService = game:GetService("UserInputService")

script.Parent.MouseButton1Click:Connect(function()
	--wait()
	cam.CameraType = Enum.CameraType.Custom
	cam.FieldOfView = 70
	player.PlayerScripts:WaitForChild("MenuCameraLocalScript"):Destroy()
	player.PlayerScripts:WaitForChild("CamFOV"):Destroy()
	playerGui:WaitForChild("ScriptsGui"):Destroy()
	--playerGui:WaitForChild("CameraRigScript"):Destroy()
	--playerGui:WaitForChild("DDD"):Destroy()
	--playerGui:WaitForChild("Language"):Destroy()
	playerGui:WaitForChild("MenuGui"):Destroy()
	playerGui:WaitForChild("PAKTCGui"):Destroy()
	playerGui:WaitForChild("StudioLogo"):Destroy()
	class.Visible = true
	Controls:Enable()
	UserInputService.MouseDeltaSensitivity = 1
	game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	game.StarterGui:SetCore("ResetButtonCallback" ,true)
end)

Move this to Scripting Support, it’ll just be easier for people who know what to do, to find it (also it is supposed to just be there and not in this category)

You should change the line where you define classGui to be after the line where you define playerGui, and change the definition to the following:

local class = playerGui.ClassGui.Main

For example like this:

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerGui = player.PlayerGui
local class = playerGui.ClassGui.Main

This is because Roblox copies the StarterGui for each person into their own PlayerGui.