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

ScreenGui is not a valid member of PlayerGui?

Asked by 6 years ago
Edited 6 years ago

Whenever I go onto a server to test my game, it doesn't work. When I checked the server logs, it says "ScreenGui is not a valid member of PlayerGui." and then it directs me to line 162, which is probably this:

for _,v in pairs(game.Players:GetChildren()) do
    v.PlayerGui.ScreenGui.TextLabel.Text = "You need 1 more player for this to start."
end

1 answer

Log in to vote
2
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

If your game has FilteringEnabled on, this wouldn't work because the server can't access the descendants of each clients' gui. If your game's not in FE, a solution has been provided

** For FE Games** You'll need to use a RemoteEvent if FE is enabled for server - client communication

--in a local script in the textlabel

local re = game.ReplicatedStorage:WaitForChild('RemoteEvent')

re.OnClientEvent:Connect(function(t)
        script.Parent.Text = t
end)
--Your server code

local re = game.ReplicatedStorage:WaitForChild('RemoteEvent')

re:FireAllClients('You need 1 more player for this to start.')

** For Non - Fe Games**

If your game doesn't have Fe enabled, you'll probably need to use :WaitForChild on the screen gui, or put a wait() before the rest of the code begins.

0
Thanks dude GIassWindows 141 — 6y
Ad

Answer this question