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

Why does studio say that ScreenGui is not a member of PlayerGui even though it is?

Asked by
kjljixx 42
3 years ago
Edited 3 years ago

When I try to run script.Parent.ScreenGui2.waiting.Text="Waiting for more players...", along with some other code, it errors out saying "ScreenGui2 is not a valid member of PlayerGui", even though it is. This code is in a localscript, and the following is the entire function containing the code.

local function clickdetection(gui)
    print(_G.notenoughplayers)
    if _G.notenoughplayers==true then
        print("not enough players")
        buttontransparency(0.5)
        script.Parent.ScreenGui2.waiting.Text="Waiting for more players..."

What makes this more confusing is that if I created a new localscript and inserted the above code, It would work. Why does it happen/How can I fix it?

0
try to use :WaitForChild() sayer80 457 — 3y
0
If this is a server-side script, there's your problem. Server-side scripts cannot access PlayerGui's descendants. DeceptiveCaster 3761 — 3y
0
It looks like you're trying to use a regular script, that cannot mess with PlayerGui. You would have to change it over to a LocalScript, and use server remotes. 2_MMZ 1059 — 3y
0
doing WaitForChild worked, thanks kjljixx 42 — 3y

Answer this question