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

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

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

2 comments

0

Your "else" is outside of one of your "if" statments

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

2 answers

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

2 comments

0

Incorrect, since the else statement is outside a conditional statement.

0

Actually it's not if you look at it.

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

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