Attempt to index nil with 'Timer' Issue

I can’t get the PlayerGui through a Script. On the console, it says attempt to index nil with 'Timer'

On the PlayerGui the GUI is there.

Screenshot of Explorer:
image

script:

1. repeat 
2. 			
3. 			for _, Player in pairs(Players:GetPlayers()) do
4. 				
5. 				local PlayerGui = Player:WaitForChild("PlayerGui")
6. 				local Timer = PlayerGui:FindFirstChild("Timer").Timer
7. 				
8. 				Timer.Text = "Waiting for players"
9. 				
10. 			end
11. 			
12. 		until GameData["Amount of Players"].Value > 3

What’s the problem here? Am I reading or writing the code wrong?
Please Help…

1 Like

Use :WaitForChild(). It should work as all UI objects load at the same time IIRC.

1 Like

I was so impatient I wanted the GUI as soon as possible lol.

Thank you for solving this.

1 Like