I'm made a script to find all players, check if they are on either the green, blue, or red teams (players who are eliminated are on none), and then add a 15 second count timer to their Gui. For some reason, the Gui doesn't work. I have the Gui all set in the PlayerGui and all, and the thing says "0:15", because that is the default, but the script does not run the countdown and I don't know why.
for i,players in pairs(game.Players:GetChildren()) do--IntervalTime Gui change if players.PlayerGui:FindFirstChild("Inno") then for t=intervaltime,15 do players.PlayerGui.Inno.TextLabel.Text = "0:"..t - 1 t = t - 1 wait(1) end elseif players.PlayerGui:FindFirstChild("Traitor") then for t=intervaltime,1,-1 do players.PlayerGui.Traitor.TextLabel.Text = "0:"..t - 1 t = t - 1 wait(1) end elseif players.PlayerGui:FindFirstChild("Detective") then for t=intervaltime,1,-1 do players.PlayerGui.Detective.TextLabel.Text = "0:"..t - 1 t = t - 1 wait(1) end end end
Well, there could be a couple of things going wrong.
1) It could be that you haven't defined intervaltime (at least you haven't if this is the whole script, which I doubt)
or
2) When setting the GUI text you shouldn't concatenate an integer onto a string. You can however, convert an integer into a string. Simply use something along the lines of the following:
players.PlayerGui.Inno.TextLabel.Text = "0:"..tostring(t-1)
or
3) When you set 't' to something other than the index in your for loop, it messes up the order. Just eliminate that line altogether. And remember to put t=intervaltime,15,-1
right after all the for loops. You have bits and pieces scattered all over.
Also, just something for you to note, the way your script is set up will only allow countdown on the players one at a time. But that's not the current issue, so cross that bridge when you get there.
Hopefully this solves the problem, and hopefully I've interpreted the problem correctly. If it doesn't work, leave a comment and we'll go from there.