Could someone point me in the right direction for changing text in everybody's screenGui? Notice, Im not asking for code to make the GUI, I just need to know the code that can access everybody's GUI.
Could someone point me in the right direction for changing text in everybody's screenGui?
2 answers
Use a for loop to loop through every player, and then go into their PlayerGui and change the text. Take a look:
for i,player in pairs(game.Players:GetPlayers()) do --Creates the for loop to loop through every player in Players.
local gui = player.PlayerGui:findFirstChild("ScreenGui"):findFirstChild("TextLabel") --Just change the GUI Hiechary after "PlayerGui" to what your GUI looks like.
if gui then --Check is the gui exists
gui.Text = "CHANGE TEXT HERE" --Sets the text of the player's GUI text.
end --Ends the if statement.
end --Ends the for loop.
game.StarterGui.ScreenGui.TextLabel.Text = "CHANGE TEXT HERE" --You'll want to keep this if you want the player's text to stick if they die. This changes the text in StarterGui, so when the GUI is cloned into the player's PlayerGui, the text is already set for them.
1 comment
This is exactly what I said to do on his last post...
So this is probably the best method I have ever found, shown to me by a friend. It works perfectly.
So in this example we will have a string value called "Notice" in game.Lighting (It doesn't actually matter where it is located or named as long as you consistently refer to it the same way always)
This will be the script that shows whatever text you want to say
local notice = game.Lighting.Notice
notice.Value = "Test"
wait(1)
notice.Value = ""
wait(3)
-- A little countdown example
for i = 30, 0, -1 do
notice.Value = "Countdown - "..i
wait(1)
end
This script will be inside the TextLabel (or whatever you are using to hold the text)
local notice = game.Lighting.Notice
Update = function()
script.Parent.Text = notice.Value
--If you had a background you wanted to hide whenever the value was empty you could even do this:
if notice.Value == "" then
script.Parent.Parent.Background.Visible = false
end
end
Update() --So that when they respawn it will show up again
notice.Changed:connect(function(Update)
And there you go! You now have an auto-updating notification GUI that shows on all player screens.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Can you give a brief description of what it is you're trying to do? There's more or less 3 vague directions you can attack this problem from, some suit some problems better