can anyone tell me how i can change everyones playergui using getplayer?
let's say i have a textlabel in a screengui inside the startgui. now how do i get all player and change the text in textlabel inside they're playergui?
Here's a script i just made while making this question so i don't really know if this will work. Will this script work or does it need some changes?
local function start () local players = game.Players:GetPlayers() players.PlayerGui.TextLabel.Text = 30 for i=1, 30 do wait(1) players.PlayerGui.TextLabel.Text = players.PlayerGui.TextLabel.Text - 1 end end)
PlayerGui
in a table. You need a for loop to index the Player
objects IN the table. Another error is on line 11. You would get an error for performing arithmetic on a string value.PlayerGui
and shouldn’t anyways! And yes I am using a RemoteEvent
to do this. You’re welcome.-- LocalScript local remote = Instance.new'RemoteEvent' remote.Name = 'GuiRemote' remote.Parent = game:GetService'ReplicatedStorage' local textlabel = script.Parent -- i put it under the textlabel remote.OnClientEvent:Connect(function() for i = 30, 0, -1 do if i == 0 then textlabel.Text = "" break end textlabel.Text = "Countdown: ".. i wait(1) end end)
-- Server script local rep = game:GetService"ReplicatedStorage" function start() -- There was a space between start and the brackets, remove it for _, v in pairs(game:GetService("Players"):GetPlayers()) do rep:WaitForChild("GuiRemote"):FireClient(v) end end
The problem is that you can't change playergui from the server.
Your best solution would be to use a remote event to send over that people should start the countdown. (Don't forget to also do the countdown on the server.)