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

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

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?

2 comments

0

Is your game Filtering Enabled?

0

Yes

2 answers

✓ Accepted answer

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

2 comments

0

I just turned off FE, and it works. I am not using LocalScripts.

0

I will accept since you cleared up the difference between FE and not FE.

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.

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