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

How do I make a countdown?

In this script how do I make a countdown so I can connect it to a string?

wait(1)
function movePlayers()--Don't mess with this
	local player = game.Players:GetPlayers()
	for i = 1, #player do
		player[i].Character:MoveTo(Vector3.new(-16, 0.5, -48))
	end
	
end
	
 
game.Players.PlayerAdded:connect(function(char)
	   
	local hint = Instance.new("Hint")
		for i = 30, 1, -1 do
		repeat wait(1)
	    if game.Players.NumPlayers >= 2 then--Change the 2 to the number of players you want to start the game
        hint.Parent = game.Workspace
		hint.Text = ("Starting the game in "..i.." seconds")--I want to have it as ("Starting game in "..i.." seconds")
		else
		hint.Text = ("Waiting for players...")
	    end
		until i == 0
		movePlayers()
		hint.Parent = game.Lighting
		end
end)

1 answer

wait(1)
function movePlayers()--Don't mess with this
    local player = game.Players:GetPlayers()
    for i = 1, #player do
        player[i].Character:MoveTo(Vector3.new(-16, 0.5, -48))
    end

end


game.Players.PlayerAdded:connect(function(char)
        if game.Players.NumPlayers >= 2 then
    local hint = Instance.new("Hint", workspace)
i = 30       
repeat
wait(1)
        hint.Text = ("Starting the game in "..i.." seconds")--I want to have it as ("Starting game in "..i.." seconds")
i = i-1
        until i <= 0
        movePlayers()
        hint.Parent = nil --Use parent = nil if you want to "remove" the hint. But you're able to bring it back.
        else
        hint.Text = ("Waiting for players...")
        end

end)

Use a repeat instead of for i = 30,1,-1.

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