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

How to change text on GUI for EVERY player, DIRECTLY?

Asked by 8 years ago

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.

3 answers

Log in to vote
0
Answered by 8 years ago

You could do:

for i,v in pairs(game.Players:GetChildren()) do
    v.PlayerGui.ScreenGui.Frame.TextLabel.Text = "Hello World"
end
Ad
Log in to vote
0
Answered by 8 years ago

[https://scriptinghelpers.org/questions/25370/how-to-send-a-notification-to-all-players-via-gui#28942]

Log in to vote
-3
Answered by
Zeoic 40
8 years ago

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.

0
Server scripts can NOT access the PlayerGui with filtering enabled. This is a poor method. User#11440 120 — 8y

Answer this question