UI not updating on Play test but works in Studio Run test

Hallo, I made a countdown that shows the time left until the round is over but when I “Play test” the game as a player, the UI does not update unless I reset while it works perfectly fine if I were to just “Run test” it.

*The game’s rounds still work perfectly fine as it’s just the client side that is not showing the updated countdown

Here’s a sample of the code: (I’m learning)

Time = 1 --Time is meant to be seconds
minutes = 0

while true do
	local gui = game:GetService("StarterGui")
	gui:WaitForChild("ScreenGui")
	Time -= 1
	
	--Intermission
	if Time == 0 and minutes == 0 then
		print("Intermission Loop started")
		timetext = ("0"..minutes..":0"..Time)

		for i = 1, 30 do
			timetext = ("Intermission (".. 31-i ..")")
			gui.ScreenGui.Time.Text = timetext
			wait(1)
		end
		
		Time = 11
		minutes = 9
		
	elseif Time < 10 and Time ~= 0 then
		timetext = ("0"..minutes..":0"..Time)
		print("seconds are defined by 1 digit")
	
	elseif Time == 0 then 
		minutes -= 1
		Time = 59
		timetext = ("0"..minutes..":"..Time)
		print("seconds are now defined by 2 digits")
	else
		timetext = ("0"..minutes..":"..Time)
	end

	print(timetext)
	gui.ScreenGui.Time.Text = timetext
	wait(.1)
end

Ahhhhhh. This is because you refer to starter gui. Dont use starter gui. Use game.Players.LocalPlayer.PlayerGui.MyGUI.

Please dont use starter gui. The reason it works in test run is because studio isnt a player so it defaults to using starter gui. But for players they use something called player gui. Each player gui has there own player gui folder. Your script is working the only thing you havw to change is the startergui thing.

4 Likes

New problem, I’m getting an error on the edited line:

image
image

How to prevent nil with “PlayerGui”?

Is it a localscript? If not it wont work.

I would appreciate it if you marked me back as the solution again.

It does not work whether it is a local script or not. It did fix the nil error though.

So then the error is solved. I solved what you ssked to solve if your it script is not working and there isnt a error thats on your side.

1 Like

It was working before editing it as you said. Anyway, thanks for the help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.