Hello, in my game, I have a very complicated and probably way too long script that changes the text of all the players' GUIs'. It basically involves this:
(This is a Script inside the Game) --> Game wait x amount of seconds --> Game changes the value of the variable "g_Var" to 1 (This is a LocalScript inside the PlayerGui) --> LocalScript that's been looping an if/then statement is now active and finally changes the text of the Gui. --> Game changes value of the variable "g_Var" back to 0 and restarts
I was wondering if there is any simple way to change the text on a GUI, for every player, DIRECTLY through a normal server Script.
You could do:
for i,v in pairs(game.Players:GetChildren()) do v.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Hello World" end
[https://scriptinghelpers.org/questions/25370/how-to-send-a-notification-to-all-players-via-gui#28942]
It is actually pretty simple, the Player's Gui is stored in "game.Players.[PLAYERNAME].PlayerGui". With this information, we can easily get the children of "game.Players" and loop through each player to change what we need.
Here is an example:
local players = game.Players:GetChildren() for i = 1, #players do players[i].PlayerGui.ScreenGui.Frame.TextLabel.Text = "Hello World" end
Note: This will not work as is if ran right at the start of a server, as no Players are connected yet.