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

How to have text label update for all Player's Gui??

Asked by 1 year ago

How can I update every one's player gui instead of only updating for 1 player's gui??

1plr.PlayerGui.Warnui.TextLabel.Text = "U are cool"

1 answer

Log in to vote
3
Answered by
pwx 1581 Moderation Voter
1 year ago

It's ideal that you use FireAllClients() with a RemoteEvent.

Put a RemoteEvent in ReplicatedStorage, be sure to name it whatever you want and edit the script accordingly.

ServerScript - Be sure to put this in ServerScriptService

1local replicatedStorage = game:GetService('ReplicatedStorage')
2 
3local Remote = replicatedStorage:WaitForChild('RemoteEvent') -- change to your remote name
4 
5Remote:FireAllClients('U are cool')

LocalScript - Be sure to put this in StarterPlayerScripts

01local replicatedStorage = game:GetService('ReplicatedStorage')
02local Players = game:GetService('Players')
03local Player = Players.LocalPlayer
04 
05local Remote = replicatedStorage:WaitForChild('RemoteEvent') -- change to your remote name x2
06 
07Remote.OnClientEvent:Connect(function(Message)
08    local warnUI = Player.PlayerGui:FindFirstChild('Warnui')
09    if warnUI then
10        warnUI.TextLabel.Text = Message
11    end -- check for UI
12end) -- on client event
1
Or you can iterate all players using Players:GetPlayers() and go to Plauer.PlayerGui to enable T3_MasterGamer 2189 — 1y
0
local Players = game:GetService("Players") T3_MasterGamer 2189 — 1y
0
for _, Player in ipairs(Players:GetPlayers()) do T3_MasterGamer 2189 — 1y
0
Player.PlayerGui:WaitForChild("Warnui").TextLabel.Text = "U are cool" T3_MasterGamer 2189 — 1y
View all comments (3 more)
0
end T3_MasterGamer 2189 — 1y
0
Thank you for your help!! theking66hayday 841 — 1y
0
T3, doing that would not be ideal due to if any UI is made by the client, and only accessible via client, using FireAllClients() allows the code to see any potential UI. pwx 1581 — 1y
Ad

Answer this question