local StarterGui = game:GetService("StarterGui")
local TextBox = StarterGui.ScreenGui.TextBox
game.Players.PlayerAdded:Connect(function(player)
for i = 1,60,1 do
TextBox.Text = i
wait(0.1) break
end
end)
Why won't the TextBox change it's Text?
2 answers
It's actually a quick fix, I've done the same issue myself in one of my own loops. (This assumes the script is in the workspace)
local StarterGui = game:GetService("StarterGui")
local TextBox = StarterGui.ScreenGui.TextBox
game.Players.PlayerAdded:Connect(function(player)
for i = 1,60,1 do
TextBox.Text = i
wait(0.1) break
end
end)
You have a "break" after the "wait(0.1)" which ends the loop right away after the first iteration, just remove it like this:
local StarterGui = game:GetService("StarterGui")
local TextBox = StarterGui.ScreenGui.TextBox
game.Players.PlayerAdded:Connect(function(player)
for i = 1,60,1 do
TextBox.Text = i
wait(0.1)
end
end)
That should do the fix, I didn't fully check the script for any other issues. (Before my relook)
Now after a relook, there's also another issue that other users were talking about in the comments, it doesn't update for other players. I also have a QUICK fix for that!
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local TextBox = StarterGui.ScreenGui.TextBox
game.Players.PlayerAdded:Connect(function(player)
for i = 1,60,1 do
for i,plr in pairs(Players:GetPlayers()) do
local TextBox = plr.PlayerGui.ScreenGui.TextBox
if TextBox then
TextBox.Text = i
end
end
wait(0.1)
end
end)
And to add to it, I think you're trying to get the amount of players, that is really easy to get!
game.Players.PlayerAdded:Connect(function(player)
playercount = #game.Players:GetPlayers()
for i,plr in pairs(game.Players:GetPlayers()) do
local TextBox = plr.PlayerGui.ScreenGui.TextBox
if TextBox then
TextBox.Text = i
end
wait(0.1)
end
end)
Sorry my answer is all over the place, but that last one should work!
3 comments
doesnt work
I did a new fix, hopefully it works, however it'll make TextBox.Text "60"
Boom, done!
You can't use a playeradded event inside of a gui or edit the startergui. Use a localscript inside of the textlabel with the following text
local TextBox = script.Parent
local iscounting = true
while iscounting do
wait(1)
if TextBox.Text ~= 0 then
TextBox.Text = TextBox.Text - 1
end
end
6 comments
But that loop just keeps going on which could cause lag.
what.. no
Well, it probably won't cause lag due to the wait(1), but the loop will still keep going because you haven't made 'iscounting' false during the loop.
if he changes iscounting to false in another function it breaks it
then how does iscounting turn to false
in a whole new function
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
This is not specific what do you want the textbox to do?
are you going to accept an answer?