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

I have a Game Problem?

I'm making a game, and when 2 or more people join the game, a countdown will start. So if there is only 1 person on the server, it will say "Waiting for 1 more player…", and then it's supposed to go 10, 9, 8… when someone else joins. It does, but only on that person's screen. The countdown doesn't start on my screen, only the other players screen. Why is this happening. I have everything in a regular script, not a local script.

Here's the script:

c = script.Parent
script.Parent.Visible = true
game:GetService("StarterGui").ResetPlayerGuiOnSpawn = false
if game.Players.NumPlayers == 1 then
	c.Text = "Waiting for 1 more player..."
elseif game.Players.NumPlayers <=2 then
c.Text = "Game Starting In..."
wait(2)
c.Text = "10"
wait(1)
c.Text = "9"
wait(1)
c.Text = "8"
wait(1)
c.Text = "7"
wait(1)
c.Text = "6"
wait(1)
c.Text = "5"
wait(1)
c.Text = "4"
wait(1)
c.Text = "3"
wait(1)
c.Text = "2"
wait(1)
c.Text = "1"
wait(1)
c.Text = "0"

end


1 comment

0

Showing the script would be helpful

1 answer

You need to access the PlayerGui for all players. A for loop is helpful for that.

--This should be in a normal script in workspace.

while wait (.1) do
	game.Players.PlayerAdded:wait()
	if game.Players.NumPlayers == 1 then
		for i, v in pairs(game.Players:GetChildren()) do
			v.PlayerGui.c.Text = "Waiting for one more player…" 	--"c" should be replaced with the path to the guy you want to change.
	else
		player.PlayerGui.c.Text = "Game preparing for play."
		wait(2)
		for i, v in pairs(game.Players:GetChildren()) do
			v.PlayerGui.c.Text = ("Game starting in " .. i .. ".") --same as above
			wait(1)
		end
	end
end

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