Answered by
7 years ago Edited 7 years ago
This is based on the assumption that there are no other parts to this script. So, technically, yes, your script would play, but only after the first person to ever start that particular server joins the game. It will never play again after that. Also, your script doesn't correctly start when a player joins, it starts when the server starts. This means that the player most likely won't see the entire message since your script will load before the player does. For a very basic setup, you're going to need tick() to account for the time passed since the server started (since someone did join to start it) and a while loop to keep running your game. You also need to take into account that the first person who joined may have left within 21 seconds of your first message, so go ahead and make sure there's someone even in the game to start it.
01 | local msg = Instance.new( "Message" , workspace) |
03 | local minimumPlayers = 1 |
09 | local serverStartTime = tick() |
10 | local delayedStart = 21 |
15 | msg.Parent = workspace |
16 | for num = startCount, stopCount, incBy do |
18 | local firstMessage = (num = = startCount) |
20 | local waitTime = firstMessage and 5 or pause |
22 | msg.Text = string.format( "The game will be starting in %s" , num) |
33 | local timeUntilStartable = ( tick() - serverStartTime ) |
35 | print (timeUntilStartable < delayedStart and math.floor(timeUntilStartable) or "We can start when there are enough players" ) |
36 | if game.Players.NumPlayers > = minimumPlayers and timeUntilStartable > = delayedStart then |