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

My script isnt working because "else" doesnt work can somebody help me?

Asked by 6 years ago

I put a then so when the players amount is less than two the game wont start but it doesnt work can somebody look at it?

while true do
     if game.Players.NumPlayers > 1 then
        h.Text = "Intermission"
        wait(1)
        h.Text = "The game will start soon.."
        wait(1)
        for i = 3, 1, -1 do
            h.Text = "Time left: " .. i
            wait(1)
        end
        h.Text = "Game ended!"
        wait(3)
        if RedVal > BlueVal then 
            h.Text = "The winner is TeamRed"
            aa:Play()
        wait(1)
        h.Text = ""
        end
        if BlueVal > RedVal then 
            h.Text = "The winner is TeamBlue"
            aa:Play()
            wait(1)
            h.Text = ""
        end
        if BlueVal == RedVal then
            wait(1)
            h.Text = "Tie! everybody wins!"
            aa:Play()
            wait(1)
        end
    end
end
else
    h.Text = "No enought players!"
    wait(1)
    end

0
Your "else" is outside of one of your "if" statments IAmKingMatt -8 — 6y
0
else is outside of the if loop you need it inside of the while true do loop and before the if statement is ended Vulkarin 581 — 6y

2 answers

Log in to vote
0
Answered by
dirk2999 103
6 years ago

You need to remove 2 'end's from above the else, and put one more below and you should be fine.

while true do
     if game.Players.NumPlayers > 1 then
        h.Text = "Intermission"
        wait(1)
        h.Text = "The game will start soon.."
        wait(1)
        for i = 3, 1, -1 do
            h.Text = "Time left: " .. i
            wait(1)
        end
        h.Text = "Game ended!"
        wait(3)
        if RedVal > BlueVal then
            h.Text = "The winner is TeamRed"
            aa:Play()
        wait(1)
        h.Text = ""
        end
        if BlueVal > RedVal then
            h.Text = "The winner is TeamBlue"
            aa:Play()
            wait(1)
            h.Text = ""
        end
        if BlueVal == RedVal then
            wait(1)
            h.Text = "Tie! everybody wins!"
            aa:Play()
            wait(1)
        end
else
    h.Text = "No enought players!"
    wait(1)
    end
end

0
Incorrect, since the `else` statement is outside a conditional statement. oSyM8V3N 429 — 6y
0
Actually it's not if you look at it. dirk2999 103 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

els has to be before one of the ends. It has to be in the script

Answer this question