Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Countdown not working?

Asked by 9 years ago

Hi guys! All I am trying to do, is display a countdown for all players at the same time and then display a message to the blue team, and a message to the green team - however I cannot get it to work :/ Any ideas? Thanks

function countdown()
  for n = 3, 0, -1 do
    for i, v in pairs(game.Players:GetPlayers()) do
      if n == 0 then --changed it!
        v.PlayerGui.Countdown.TextLabel.Visible = true
        v.PlayerGui.Countdown.TextLabel.Text = n
        if v.TeamColor == BrickColor.new("Bright green") then
          v.PlayerGui.Countdown.TextLabel.Text = "Escape!"
        elseif v.TeamColor == BrickColor.new("Bright blue") then
          v.PlayerGui.Countdown.TextLabel.Text = "Shoot the escapers!"
        else
          print ("They don't get a countdown 'cause they are not playing the game")
        end
      else
        v.PlayerGui.Countdown.TextLabel.Visible = false
        v.PlayerGui.Countdown.TextLabel.Text = ""
      end
    end
    wait(1)
  end
end

1 answer

Log in to vote
0
Answered by
xAtom_ik 574 Moderation Voter
9 years ago

Your making it display 0... Its displaying the countdown once its finished because of the

if n == 0 then

Try this code

function countdown()
  for n = 3, 0, -1 do
    for i, v in pairs(game.Players:GetPlayers()) do     
        v.PlayerGui.Countdown.TextLabel.Visible = true
        v.PlayerGui.Countdown.TextLabel.Text = n
        if n == 0 then --changed it!
            if v.TeamColor == BrickColor.new("Bright green") then
            v.PlayerGui.Countdown.TextLabel.Text = "Escape!"
            elseif v.TeamColor == BrickColor.new("Bright blue") then
                v.PlayerGui.Countdown.TextLabel.Text = "Shoot the escapers!"
            else
                print ("They don't get a countdown 'cause they are not playing the game")
            end
        else
             v.PlayerGui.Countdown.TextLabel.Visible = false
             v.PlayerGui.Countdown.TextLabel.Text = ""
      end
    end
    wait(1)
  end
end
0
Thanks - this displays the message but not the countdown :/ Any ideas? jjwood1600 215 — 9y
Ad

Answer this question