Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

GUI that is clearly in PlayerGui is not a valid member of PlayerGui?

I've got this in a LocalScript inside a screenGui named Top.

local player = game.Players.LocalPlayer

local TabFrame = player.PlayerGui.Interface.Frame -- This is where the error is occuring

local back = script.Parent.Parent.Parent.Parent.Back

if player.PlayerScripts.TutorialComplete == false or game.Players.LocalPlayer.PlayerScripts.DevMode.Value == true then
	local TutNotif = script.TutorialQuery:Clone()
	TutNotif.LayoutOrder = back.Order.Value
	TutNotif.Parent = script.Parent.Data
	
	back.Notifs[TutNotif.Name].Confirm.MouseButton1Click:Wait()
	
	TutNotif:Destroy()
	back.Notifs[TutNotif.Name]:Destroy()
	
	local TutNotif = script.TutorialTask1:Clone()
	TutNotif.LayoutOrder = back.Order.Value
	TutNotif.Parent = script.Parent.Data
	
	local target = TabFrame["1Broadcasting"].BroadcastSettings.Back.Title
	TutNotif.Tab1.Visible = true
	
	target.BackgroundTransparency = 0.5
	target.BackgroundColor3 = Color3.fromRGB(0, 124, 20)
	
	target.FocusLost:Wait()
	
	target.BackgroundTransparency = 1
	target.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	
	local target = TabFrame["1Broadcasting"].BroadcastSettings.Back.Desc
	TutNotif.Tab1.Visible = false
	TutNotif.Tab2.Visible = true
	
	target.BackgroundTransparency = 0.5
	target.BackgroundColor3 = Color3.fromRGB(0, 124, 20)
	
	target.FocusLost:Wait()
	
	target.BackgroundTransparency = 1
	target.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	
	local target = TabFrame["1Broadcasting"].BroadcastSettings.Back.Tags
	TutNotif.Tab2.Visible = false
	TutNotif.Tab3.Visible = true
	
	target.BackgroundTransparency = 0.5
	target.BackgroundColor3 = Color3.fromRGB(0, 124, 20)
	
	target.FocusLost:Wait()
	
	target.BackgroundTransparency = 1
	target.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	
	local target = TabFrame["1Broadcasting"].BroadcastSettings.Back.PublicAPI
	TutNotif.Tab3.Visible = false
	TutNotif.Tab4.Visible = true
	
	target.BackgroundTransparency = 0.5
	target.BackgroundColor3 = Color3.fromRGB(0, 124, 20)
end

I get the error

Interface is not a valid member of PlayerGui

but a screenGui named Interface is clearly inside playerGui. I'm completely lost, I've used this same way to get Gui millions of times before without error. What am I doing wrong?

Heres the, relevant, file structure.

StarterGui
	? Interface (ScreenGui)
	? Top (ScreenGui)
		? TopBar (Frame)
			? Frame (Frame)
				? UIListLayout (UIListLayout)
				? Frame (Frame)
					? Notifs (ImageButton)
						? Data (Folder)
						? Tutorial (This script)
						? Alarm (ImageLable)

Its the same in PlayerGui as well.

1 answer

I don't see anything initally wrong with your code, the most possible cause is that this code is being ran before Interface is being created (yeah roblox is a bit weird sometimes).

Try adding some WaitForChild()'s and see if that fixes the problem.

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local Interface = PlayerGui:WaitForChild("Interface")

This discussion is preserved as it was. New answers, comments, and votes are closed.