Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[SOLVED] How to fix: 'PlayerGui is not a valid member of PlayerGui'???

Asked by 4 years ago
Edited 4 years ago

I have a ScreenGui named 'PlayerGui' and inside the gui, there is a Frame.

In a localscript under a different ScreenGui I want to hide the 'Frame' inside PlayerGui.

My script:

script.Parent.Parent.PlayerGui.Frame.Visible = false

This script doesn't work, and roblox outputs with this message: "PlayerGui is not a valid member of PlayerGui"

I tried another script:

game.StarterGui.PlayerGui.Frame.Visible = false

This script also doesn't work, and outputs with the same message.

I have double checked everything and can 100% guarantee that everything is under StarterGui and its ScreenGui.

How do I fix this problem?

0
Btw I just checked the visibility under Frame and it checked visible but Im not sure why it's not visible when it's checked visible JealousRegretHate 34 — 4y
0
Srry if the names r a little bit confusing JealousRegretHate 34 — 4y
0
did you try putting it into a serverscript and using the 2nd piece of code you put? MLGwarfare04 183 — 4y
0
The problem is that the script is working, and the visible box is checked in 'Frame' but the actual thing is not showing, and I don't have any other code stopping it from not showing JealousRegretHate 34 — 4y
0
I even added a print("visible") and it printed "visible" but the frame is not showing! Is this a roblox studio bug or something? JealousRegretHate 34 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

When you try to change a UI in the PlayerGui of the Player, you need a LocalScript. Put this in the StarterGui

When you're in a LocalScript you can find who is the Client "Player"

LocalScript

local PlayerService = game:GetService('Players') -- This is the folder that you can see in the Explorer. Here the Players connected at your game.

local Player = PlayerService.LocalPlayer -- Here you can find  the Client
local PlayerGui = Player:WaitForChild('PlayerGui') -- Here you find the PlayerGui.
local ScreenGui = PlayerGui:WaitForChild('ScreenGui') -- Here you find the PlayerGui.

ScreenGui:WaitForChild('Frame').Visible = false

StarterGui is where your ScreenGui that replicate to the Clients. You doesn't need that.

0
OMG UR A LEGEND IT WORKED TY SO MUCH LIKE TY JealousRegretHate 34 — 4y
Ad

Answer this question