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

What is wrong with this script? Can Someone fix it for me? ANSWERED

What I want to do is basically to make an intermission that will eventually transition into a match that will start depending on the number of players in the game.** I want it so that at least 4 players are in the game for the match to start. I want it to start counting down the check the number of players in the lobby. **

hint = script.Parent
minplayers = 4


function CheckForPlayers()
	if game.Players.NumPlayers <= minplayers then
		hint.Text = "You need at least "..minplayers.." to start a match."
		Countdown()
	else
		wait (1)
		hint.Text = "Starting Match in: 5"
		wait(1)
		hint.Text = "Starting Match in: 4"
		wait(1)
		hint.Text = "Starting Match in: 3"
		wait(1)
		hint.Text = "Starting Match in: 2"
		wait(1)
		hint.Text = "Starting Match in: 1"
		wait(1)
		hint.Text = "Starting Match in: 0"
		wait(2)
		hint.Text = "Starting Match."
		wait(1)
		hint.Text = "Starting Match.."
		wait (1) 
		hint.Text = "Starting Match..."
		wait(1.1)
		hint.Text = "Starting Match."
		wait(1)
		hint.Text = "Starting Match.."
		wait (1) 
		hint.Text = "Starting Match..."
		wait(2)
		hint.Text = "Starting Match."
		wait(1)
		hint.Text = "Starting Match.."
		wait(1) 
		hint.Text = "Starting Match..."
		wait(1.1)
		hint.Text = "Starting Match."
		wait(1)
		hint.Text = "Starting Match.."
		wait (1) 
		hint.Text = "Starting Match..."
	end
end

function Countdown()
	local i = 30
	while i > -1 do
		wait (1)
		hint.Text = "Intermission: " .. i
		CheckForPlayers()
		i = i - 1
	end
	hint.Parent.Visible = true
end

4 comments

0

So, what about this code doesn't work?

0

Nothing works. Nothing Happens and I dont know why..

0

Do you get any Output?

0

it says end is expected to close if at line 6

1 answer

✓ Accepted answer

Mate, you forgot to call your function. If you don't call your function, nothing will run if it is inside of a function.

hint = script.Parent
minplayers = 4


function CheckForPlayers()
    if game.Players.NumPlayers < minplayers then
        hint.Text = "You need at least "..minplayers.." to start a match."
        Countdown()
    else
        wait (1)
        hint.Text = "Starting Match in: 5"
        wait(1)
        hint.Text = "Starting Match in: 4"
        wait(1)
        hint.Text = "Starting Match in: 3"
        wait(1)
        hint.Text = "Starting Match in: 2"
        wait(1)
        hint.Text = "Starting Match in: 1"
        wait(1)
        hint.Text = "Starting Match in: 0"
        wait(2)
        hint.Text = "Starting Match."
        wait(1)
        hint.Text = "Starting Match.."
        wait (1) 
        hint.Text = "Starting Match..."
        wait(1.1)
        hint.Text = "Starting Match."
        wait(1)
        hint.Text = "Starting Match.."
        wait (1) 
        hint.Text = "Starting Match..."
        wait(2)
        hint.Text = "Starting Match."
        wait(1)
        hint.Text = "Starting Match.."
        wait(1) 
        hint.Text = "Starting Match..."
        wait(1.1)
        hint.Text = "Starting Match."
        wait(1)
        hint.Text = "Starting Match.."
        wait (1) 
        hint.Text = "Starting Match..."
    end
end

function Countdown()
    local i = 30
    while i > -1 do
        wait (1)
        hint.Text = "Intermission: " .. i
        CheckForPlayers()
        i = i - 1
    end
    hint.Parent.Visible = true
end

CheckForPlayers() --This is calling your function. This will run the code inside the function CheckForPlayers, which will call Countdown as you placed inside of the original function.

If I helped you, be sure to press the Accept Answer button below my character! :D

1 comment

0

You could of used the "for" as a easier way.

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