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

Why is this erroring on a server, but not in studio?

Asked by
Azmidium 388 Moderation Voter
8 years ago

I made a method that triggers if there isn't enough players on the game called AnnounceMsg() . It takes in a string that announces a message. Here is the function:

function AnnounceMsg(message)
    for _, player in pairs (game.Players:GetChildren()) do
        player:WaitForChild("PlayerGui").Announcements.Backing.Announcements.Text = message
    end
end

I am getting the error:

Announcements is not a valid member of PlayerGui

BUT! The problem is it is a member of PlayerGui. Any help?

0
Is your game Filtering Enabled? Shawnyg 4330 — 8y
0
Yes Azmidium 388 — 8y

2 answers

Log in to vote
1
Answered by 8 years ago

Problem

The only problem I can see is that since it works in studio and not in server it should be a latency problem, this happens because in studio everything is pretty much local so you don't have to wait for a server to create stuff so your local scripts run instantly. In server this doesn't happen as when a local scripts cause upons something in player or character that is server-sided then the local script is "local" which makes it run faster then the server can respond.

Solution

repeat wait() until game.Players.LocalPlayer.Character--To the top of every local script
0
I just turned off FE, and it works. I am not using LocalScripts. Azmidium 388 — 8y
0
I will accept since you cleared up the difference between FE and not FE. Azmidium 388 — 8y
Ad
Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
8 years ago

Ah, your game is FilteringEnabled. You can only access a player's PlayerGui serversided. Meaning, the script will have to be a server script (normal, not local), and placed in ServerScriptService. To cooperate with FilteringEnabled, I recommend looking into the RemoteEvents and RemoteFunction tutorial.

Answer this question