I wanted to change the Text in my ScreenGui textlabel but there seem to be impossible based on the result I tried to find in this platform and google.
I tested this code which was said to supposedly work. I’ve check many times for misspelt in the code or the name of the textlabel, everything is fine. So I don’t know why its not working…
This target only a single user game.Players.Playername.PlayerGui.ScreenGui.Textlabel.Text = "Hello World"
This loop thru every players
for _,v in pairs(game.Players:GetChildren()) do
v.PlayerGui.ScreenGui.TextLabel.Text = "Hello World"
end
for i, Player in pairs(game:GetService'Players':GetPlayers()) do
Player:WaitForChild'PlayerGui':WaitForChild'ScreenGui':WaitForChild'TextLabel'.Text = "Hello World"
end
Its working fine for me, whats the problem?
Btw, when the serverscript starts, the player is not in server yet, the character delays time to spawn, so try adding a wait(10) just for test. You are maybe trying to change a text that doesnt exist yet in the client, cause theres no client in server.
wait(10)
print("change now")
for _,v in pairs(game.Players:GetChildren()) do
v.PlayerGui.ScreenGui.TextLabel.Text = "Hello World"
end
Oh yeah I get what you’re saying
maybe try and connect it to a PlayerAdded event as well instead of loops
Because of there is nothing inside a table and a loop tries to loop through it I’m pretty sure the script just ignores that code
I think that theres no error, because its iterating into the Clientes in server, and because there is no client when the code is running, then it never does the v.PlayerGui.ScreenGui.TextLabel.Text = "Hello World"
When I tested the code with the wait(10) everything works fine
EDIT: And @legs_v is totally right. Managing this on events when the player join is the best idea. The wait(10) was just for testing