Why isnt this player script working? The output says attempting to call global start match a nil value. Can someone help me fix this script ?
hint = script.Parent minplayers = 0 function CheckForPlayers() end if game.Players.NumPlayers == minplayers then hint.Text = "You need at least "..minplayers.." players to start a match." Countdown() end StartMatch() function StartMatch() 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 StartMatch() function Countdown() local i = 30 while i > -1 do wait (1) hint.Text = "Intermission: " .. i i = i - 1 end hint.Parent.Visible = true end Countdown()
Your problem is that you are calling the StartMatch
function before you define it. I fixed your code and added some for loops to make it shorter. Also please make sure you are tabbing your code properly. It is very hard to read without tabs.
Also why do you have an empty function? You are only checking for players once so if more players join nothing will happen.
But I fixed the part of your script with the error.
hint = script.Parent function StartMatch() for i=5,0,-1 do hint.Text = "Starting Match in: "..i wait(1) end wait(2) for i=1,12 do hint.Text = "Starting Match"..string.rep(".",i%3.01) wait(1) end end StartMatch() function Countdown() for i=30,0,-1 do hint.Text = "Intermission: "..i wait(1) end hint.Parent.Visible = true end Countdown()