PlayerGui not Enabling in LocalScript:

Hello there,

Today, on Roblox Studio, I decided to make a LocalScript on a primary frame that while firing other events alongside services that were counted in the code lines, would also enable other ScreenGUIs:

local Game_Workspace = game.Workspace
local Game_StarterGui = game.StarterGui
local Game_Terrain = game.Workspace.Terrain
local Game_Assets = {Game_Workspace, Game_StarterGui, Game_Terrain}
local Players = game:GetService("Players")
local ContentProvider = game:GetService("ContentProvider")
--local Game_Camera = game.Workspace.Camera
--local Player = game.Players.LocalPlayer.Character
local BadgeGUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("BadgeGui")
local CoinGUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("CoinGui")
local DiamondGUI = game.Players.LocalPlayer.PlayerGui:FindFirstChild("DiamondGui")

Players.PlayerAdded:Connect(function(player)
	print("Welcome" .. " @" .. player.Name .. ".")
end)

--Game_Camera.CameraSubject = game.Workspace.CameraPart
--Game_Camera.CameraType = Enum.CameraType.Track
--Game_Camera.CFrame = CFrame.new(Vector3.new(game.Workspace.CameraPart.Position + game.Workspace.CameraPart.Orientation))

task.wait(3.75)

local MainGUI = Players.LocalPlayer.PlayerGui.MainFrame
MainGUI.LoadingFrame.X.TextTransparency = 1
MainGUI.LoadingFrame.Roblox_Logo.ImageTransparency = 1
MainGUI.LoadingFrame.Steampunk_Logo.ImageTransparency = 1
MainGUI["English Forest 14 (SFX)"]:Play()

BadgeGUI.Enabled = false
BadgeGUI.BadgeFrame.Visible = false

CoinGUI.Enabled = false
CoinGUI.CoinFrame.Visible = false

DiamondGUI.Enabled = false
DiamondGUI.DiamondFrame.Visible = false

task.wait(5)

if MainGUI then
	while true do
		local number = 1
		local FullView = number - 0.1
		task.wait(0.01)
		MainGUI.LoadingFrame.X.TextTransparency = FullView
		if MainGUI.LoadingFrame.X.TextTransparency <= 0 then
			print(MainGUI.LoadingFrame.X.TextTransparency)
	--		break
		end
		MainGUI.LoadingFrame.Roblox_Logo.ImageTransparency = FullView
		if MainGUI.LoadingFrame.Roblox_Logo.ImageTransparency <= 0 then
			print(MainGUI.LoadingFrame.Roblox_Logo.ImageTransparency)
	--		break
		end
		MainGUI.LoadingFrame.Steampunk_Logo.ImageTransparency = FullView
		if MainGUI.LoadingFrame.Steampunk_Logo.ImageTransparency <= 0 then
			print(MainGUI.LoadingFrame.Steampunk_Logo.ImageTransparency)
	--		break
		end
		task.wait(10)
		break
	end
end

task.wait(5)

game.Workspace.SpawnLocation:Destroy()

ContentProvider:PreloadAsync(Game_Assets)
print("Loaded")

task.wait(5)

--Game_Camera.CameraSubject = Player:FindFirstChildOfClass("Humanoid")
--Game_Camera.CameraType = Enum.CameraType.Custom
MainGUI["English Forest 14 (SFX)"]:Stop()

MainGUI.Enabled = false

BadgeGUI.Enabled = true
BadgeGUI.BadgeFrame.Visible = true

CoinGUI.Enabled = true
CoinGUI.CoinFrame.Visible = true

DiamondGUI.Enabled = true
DiamondGUI.DiamondFrame.Visible = true

Players.PlayerRemoving:Connect(function(player)
	print("@" .. player.Name, "left the experience.")
end)

(NOTE: Those that are as in comments were moved to other properties at the game on the Studio engine)

Once testing the script while playing, it prints errors upon the Output saying that it is trying to attempt to index nil within enabling the GUI:

image

This happens to have BadgeGUI, CoinGUI, and DiamondGUI + Its frames are false and true in certain moments.

Within the result, I want to know how I can solve this problem to truly make it activated using .Enabled function. If anyone can help me with this, I would appreciate it a lot!

Thank you!

It ends at MainFrame as i saw it on Output, perhaps it has to do with parenting?

Quite ends at MainFrame, but once clicking in the error at the Output, it brings me to the BadgeGUI being false as .Enabled…

I see, but this line seems like it’s parenting to Frame instance instead, are you sure this is ScreenGui?
Screenshot_25651118_221536

Yup! The name of the ScreenGUI is called ā€œMainFrameā€ once creating for the first time for the experience at Roblox Studio:

image

You are trying to enable the script, instead of the SGui. (If you’re trying to enable/disable scripts, it’s a Disabled property instead)

From the output screenshot, you are indexing the local script rather than the gui. Make sure you are indexing the right thing

So instead of having the property .Enabled, I should put like this?

BadgeGUI.Disabled = true

no make sure you are indexing BadgeGui correctly. It seems you are indexing the local script. Is your local script also named ā€˜BadgeGui’. If so, change it

I am not indexing the LocalScript to be enabled/disabled, I am trying to get the ScreenGui called ā€œBadgeGuiā€ (and others) to be activated using .Enabled after seconds. Also, the name of the script is simply called as ā€œLocalScriptā€

your output is saying otherwise tho. Make sure your variables are correct

I know it says otherwise, yet it directs me to the variable called BadgeGUI for some reason… (And yes, I checked the variables if they are correct before and afterward)

Unsure if this is a bug or a programming error in the script…

StarterGui is not where you should check, how about show us the PlayerGui instead? as they clone GUI’s to there.

it’s in Players > [username]

1 Like

Sure, here:

image

The GUIs that are mostly having issues are set as not enabled, except for MainFrame.

try to switch from
.PlayerGui:FindFirstChild
to
.PlayerGui:WaitForChild

2 Likes

although i think it has to be Getting children, 3 of your GUIs were working properly but the ones for MainFrame are different here’s what i think solves the issue. (i wasn’t on PC so this might not work)

local MainGUI = Players.LocalPlayer.PlayerGui:WaitForChild("MainFrame")
1 Like

I tried doing this in the variable MainGUI, yet remains leading to BadgeGUI:

image

hmm i have to solve it tomorrow, can you DM me a place file? I’ll probably check what happens to the code line. (doesn’t need to be your entire game)

1 Like