Why doesn't this script work

  1. What do you want to achieve? I want the game to say how many players there are and if there are more than 2 players in the game the intermission will countdown. And after the countdown it says Games begin!

  2. What is the issue? The script doesn’t work.

  3. What solutions have you tried so far? Changing the script.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

if #game.Players:GetPlayers() < 2 then
	game.StarterGui.ScreenGui.TextLabel.Text = "Not enough players in the game"..#game.Players:GetPlayers()"/2"
end

for i = 30,1,-1 do
		game.StarterGui.ScreenGui.TextLabel.Text = "Intermission "..i
	wait(1)
	
end
	game.StarterGui.ScreenGui.TextLabel.Text = "Game begins" 
   
	

I think the problem is somewhere above where i wanted to know the numbers of players in the game. Because before i put if #game.Players:GetPlayers() < 2 then game.StarterGui.ScreenGui.TextLabel.Text = "Not enough players in the game"..#game.Players:GetPlayers()"/2" It worked just fine with the other code. I appreciate you for helping

2 Likes

It will work, but not for player in the game.
player have PlayerGui.

Replace game.StarterGui with player.PlayerGui.
I hope you have player variable stored somewhere in your script.

3 Likes
game.StarterGui.ScreenGui.TextLabel.Text = "Not enough players in the game"..#game.Players:GetPlayers()"/2"

You didn’t concatenante the “/2” after :GetPlayers().

This should work

game.StarterGui.ScreenGui.TextLabel.Text = "Not enough players in the game"..#game.Players:GetPlayers().."/2"
3 Likes

Both do the same. Except, GetPlayers() returns only the players

2 Likes

Dont use StarterGui. When the player is in game, its PlayerGui.

3 Likes

Oh rip didn’t notice I just copy and pasted

3 Likes
local Players = game:GetService("Players"):GetChildren()
local Players = game:GetService("Players"):GetPlayers()

Both of these are tables of the players in the game.
The only difference is,
the second one will only get the instances that are Players.

If you would want to get the Players of a team for example, you’ll have to use GetPlayers().

2 Likes

if #game.Players:GetPlayers() < 2 then
game.PlayerGui.ScreenGui.TextLabel.Text = “Not enough players in the game”…#game.Players:GetPlayers()…"/2"
end

for i = 30,1,-1 do
game.PlayerGui.ScreenGui.TextLabel.Text = "Intermission "…i
wait(1)

end
game.PlayerGui.ScreenGui.TextLabel.Text = “Game begins”

why doesnt that work

1 Like
game.Players.PlayerAdded:Connect(function(player)

    repeat wait(1) 
        player.PlayerGui.ScreenGui.TextLabel.Text = "Not enough players in the game"..#game.Players:GetPlayers().."/2"
    until #game.Players:GetPlayers() < 2

    for i = 30,1,-1 do
        player.PlayerGui.ScreenGui.TextLabel.Text = "Intermission "..i
        wait(1)

    end
    player.PlayerGui.ScreenGui.TextLabel.Text = "Game begins"
end)
2 Likes

can you show your whole code? that would help a lot

also changing startergui doesnt replicate to all players lol

2 Likes

I don’t think you should post the whole script because that wasn’t allowed but it still helped and now it works so thx alot.

The script is pretty much your script that you posted the reply above me, I just fixed some mistakes you made like doing game.PlayerGui instead of player.PlayerGui, so to get the player I wrapped it in a player added event. Lastly I changed it to use a repeat wait() until instead of your if statement so that it will keep checking until there is more than 2 players, instead of checking one time, then continuing the code. Theres your explanation so now its perfectly allowed :slight_smile: lol

thanks :joy: !!!