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

Why won't my script locate the ScreenGui in PlayerGui?

I have a part in my game that when clicked on, checked using a click detector, the gui 'ScreenGui' should enable. However, I simply get an error that states 'ScreenGui is not a valid member of PlayerGui'. Filtering is enabled.

script.Parent.ClickDetector.MouseClick:connect(function(playerWhoClicked)
	local player = playerWhoClicked
	player.PlayerGui.ScreenGui.Enabled = true
end)

3 answers

In FilteringEnabled, you cannot access the contents of a Player's PlayerGui UNLESS you placed something in there from the server.

What you are trying to do will not be valid in FilteringEnabled.

One way to get around this is to have the ScreenGui object located somewhere the script can access (such as inside the script itself), and then clone the ScreenGui to place it inside the plr's PlayerGui.

For example:

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	script.ScreenGui:Clone().Parent = plr.PlayerGui
end)

Try this:

script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	plr:WaitForChild('PlayerGui'):WaitForChild('ScreenGui').Enabled = true
end)

3 comments

0

It says:

0

It outputs an error, stating that there's an infinite yield possible.

0

Then screenGui isn't in PlayerGui

Make sure its a local script a script cannot access the player gui when filtering enabled is turned on.

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