GUI updates on client but not server

I’ve been starting to play around with GUIs a little bit and wanted to create an intermission countdown timer. The timer does update and work correctly on the client, but it does not update on the server.

Local Script in GUI:

local intermissionTime = game:GetService("ReplicatedStorage"):WaitForChild("Variables").intermissionTime

script.Parent.time.Text = intermissionTime.Value

intermissionTime.Changed:Connect(function()
	script.Parent.time.Text = intermissionTime.Value
end)

Main Script in ServerScriptService

local intermissionTime = game:GetService("ReplicatedStorage"):WaitForChild("Variables").intermissionTime
game.StarterGui.intermissionGUI.Enabled = true
		
for i = 15, 0, -1 do
	wait(1)
	intermissionTime.Value = intermissionTime.Value - 1
			
	if intermissionTime.Value == 0 then
		break
	end
end

I was wondering if this is bad practice and how to fix it. The code works as intended, but the timer does not update on the server, only the client.

ah I see the problem, you are trying to change something in StarterGui. Startergui replicates everything in it into a thing inside the player called PlayerGui.

Local scripts only run on the client, so you won’t notice anything on the server (because it won’t run there).

It’s fine, though; UI doesn’t show at all in the server (there’s no local player), so it doesn’t matter if it updates there or not. When a player joins in, the GUI will replicate to them, the code will run, and the UI will update; so they won’t notice any difference.

2 Likes

Okay, that does make sense since there is no LocalPlayer on the server.

Thanks for the input!