0

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

smd34 30
7 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

0
0
Nothing works. Nothing Happens and I dont know why.. smd34 30 — 7y
0
Do you get any Output? adark 5487 — 7y
0
it says end is expected to close if at line 6 smd34 30 — 7y

1
Discern 1007
7 years ago

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

0
You could of used the "for" as a easier way. woodengop 1134 — 7y