New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
Log in to vote

Changing a GUI in the PlayerGui Folder?

Asked by
Nickelz 37
2 years ago
Edited 2 years ago

I am trying to make a script that changes all players gui from the PlayerGui folder, I got a snippet of code out of another script but it is not working for me.

players = game.Players:GetChildren()
    for i=1, #players do
        players.PlayerGui.InformationGui.maintext.Text = "Example"

1 answer

Log in to vote
Answered by 2 years ago
Edited 2 years ago


The Issue

The basic issue is that players is an array, so of course it is not going to work. I don't usually use this kind of loop when doing this kind of thing, I like to use pairs.


I would approach it like this:

for _,player in pairs(game.Players:GetChildren()) do
    player.PlayerGui.InformationGui.maintext.Text = "Example"

Or you could approach it like this (source):

local plrs=game.Players:GetPlayers()
for i=1,#plrs do
    output=plrs[i].PlayerGui.InformationGui.maintext.Text = "Example"


Thanks for reading my answer! I hope it helped. ~NowUndoThatMistake


Answer this question