Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[UNANSWERED] Why won't my GUI work when accessing it in ServerScriptService?

function Start()
    for i = 10, 0, -1 do
        game.StarterGui.Intermission.TextLabel.Text = "Game beginning in "..i
        wait(1)
    end
end

while true do
    if game.Players.NumPlayers >= 3 then
        wait(1)
        Start()
    end
    wait()
end

1 comment

1

StarterGui is just the Gui that is given when a player spawns. It doesn't update live with all clients.

3 answers

✓ Accepted answer

If you're testing it as a player, that's because what is in the StarterGui does not automatically update with every player. The StarterGui is what's replicated into a player's PlayerGui when they spawn. Here is an edited version of your script:

function Start()
    for i = 10, 0, -1 do
	for i, player in pairs(game.Players:GetPlayers()) do
		if player:FindFirstChild("PlayerGui") and player.PlayerGui:FindFirstChild("Intermission") then
        		player.PlayerGui.Intermission.TextLabel.Text = "Game beginning in "..i
		end
	end
        wait(1)
    end
end


while true do
    if game.Players.NumPlayers >= 3 then
        wait(1)
        Start()
    end
    wait()
end

1 comment

0

This isn't suggested, but would work. For use with FilteringEnabled, it is suggested to use a RemoteEvent fired from the server and handled in a LocalScript.

StarterGui is just a container for GUIs. Whenever a player spawns, the ROBLOX engine automatically makes a copy of everything in StarterGui and pastes it into the Player's PlayerGui object. That's why you don't see any affect when you change the properties of an object in StarterGui.

The startergui will update, but Not update playerguis.

This discussion is preserved as it was. New answers, comments, and votes are closed.