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

Could somone point me in the right direction for changing text in everybody's screenGui?

Asked by 9 years ago

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.

2 answers

Log in to vote
1
Answered by
Muoshuu 580 Moderation Voter
9 years ago

Try using a 'for' loop to loop through the players.

An example?

for k,Player in pairs(game.Players:GetChildren()) do
    Player.PlayerGui.ScreenGui.TextLabel.Text="Hello world!"
end
0
Edited Muoshuu 580 — 9y
0
Didnt work, No output in the developer menu or regular output window for studio. My_Comment 95 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

Answer this question