Gui enabling error

Hello! I am trying to make “mainGui” visible after clicking a button so it doesn’t interfere with “IntroGui”. I set mainGui disabled on the properties tab, and I thought doing Enable = true would work especially when using PlayerGui, but it did not. Although, I did check that it was enabled on the property afterwards, but it did not become visible in the game. Is there a better approach to this?

local TweenService = game:GetService("TweenService")
local StartButton = script.Parent

local Camera = workspace.CurrentCamera
local CamPart = workspace.CamPart

local Lighting = game.Lighting
local FogEnd = Lighting.FogEnd
---------------------------------------
local StarterGui = game:GetService("StarterGui")

local ScreenGui = script.Parent.Parent
local Blackframe = ScreenGui.BlackFrame

local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local mainGui = playerGui:FindFirstChild("MainGui")

local function fade(element, property, targetValue, duration)
	local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
	local propertyTable = {}
	propertyTable[property] = targetValue

	local tween = TweenService:Create(element, tweenInfo, propertyTable)
	tween:Play()
end

StartButton.MouseButton1Click:Connect(function()
fade(Blackframe, "BackgroundTransparency", 0, 0.5)
	task.wait(1)
	mainGui.Enabled = true
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = CamPart.CFrame
	FogEnd = 150
	fade(Blackframe, "BackgroundTransparency", 1, 0.5)
end)

:FindFirstChild will return nil if the object does not exist yet, try :WaitForChild.

Thanks, it worked! I apparently made an mistake with defining the gui’s name, but WaitForChild() did work too.