ked2000Join Date: 2011-07-10 Post Count: 1059 |
I have a function definition called run() at line 174. It continues running in a endless loop. I do not know what this error means, I have never had it before. I do not want to post a whole block of code if it won't help. I looked this error up but I did not find anything.
Can someone tell me what's causing this(I will post the code if need be)?
Error:
Workspace.Main: 174: Game script timeout |
|
|
its becuz ur code is horrible |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
o rlly? lemme se ur code. |
|
|
post ur code and i can help |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
All of it or just run()? |
|
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
function run()
while true do
local currentSet = {};
if (sets[chosenSet]) then
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
print("Starting next game")
local gui = player:FindFirstChild("PlayerGui").TextGui
gui.Frame1.TextBox.Text = "Welcome to True or false!"
wait(4)
for i = 5, 0, -1 do gui.Frame1.TextBox.Text = "Beginning in "..i.." seconds." end
chooseSet()
gui.Frame1.TextBox.Text = chosenSet.." set selected!"
local index;
index, currentSet = chooseQuestions(currentSet)
print("Got "..#currentSet.." questions in current set "..chosenSet)
teleportPlayer(player, -9.3, 54.99, -461.5)
for i, v in pairs(out) do if (v:lower() == player.Name:lower()) then table.remove(out, i)end end
table.insert(playing, player.Name)
wait(3)
gui.Frame1.TextBox.Text = "There are "..#currentSet.." questions in the "..chosenSet.." set!"
wait(3)
gui.Frame1.TextBox.Text = sets[chosenSet].Reward.." Bronze Coins will be awarded to the winners per round."
wait(3)
for i = 1, index do
gui.Frame1.TextBox.Text = "Question "..i.."!"
wait(3)
ask(currentSet[i])
end
print("Finishing game.")
gui.Frame1.TextBox.Text = "Game Over!"
wait(3)
gui.Frame1.TextBox.Text = "The winner(s) are : "..table.concat(playing, ", ").."! Congratulations!"
wait(3)
gui.Frame1.TextBox.Text = "The winner(s) are being awarded "..sets[chosenSet].Reward.." Bronze Coins."
award(playing)
intermission()
end
end
end
end
|
|
|
You should take the loop out and do this instead
while wait() do
run()
end |
|
|
*
Make sure to remove award and intermission from run()
while wait() do
run()
award(playing)
intermission()
end |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
Didn't work. |
|
|
Is this ever true?
if (sets[chosenSet]) then |
|
|
Trying to figure out why the script isn't waiting |
|
|
|
You have an infinite loop somewhere |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
sets[chosenSet] returns true because it exists.
The only loop that runs forever is in run() |
|
|
When do you get the error?
Does the game at least start? |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
I get the error once the server loads(AKA. When I join the game). The game doesn't start because it errors where I call it. |
|
|
That happens because there aren't any players when the server starts and all the waits are located in the player loop
That means my script works but you didn't use it :( |
|
|
Or before calling run
repeat wait(.1) until #game.Players:GetPlayers() > 0 |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
I tried your methods and I added a function to wait for players, I still get the error. |
|
|
function run()
local currentSet = {};
if (sets[chosenSet]) then
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
print("Starting next game")
local gui = player:FindFirstChild("PlayerGui").TextGui
gui.Frame1.TextBox.Text = "Welcome to True or false!"
wait(4)
for i = 5, 0, -1 do gui.Frame1.TextBox.Text = "Beginning in "..i.." seconds." end
chooseSet()
gui.Frame1.TextBox.Text = chosenSet.." set selected!"
local index;
index, currentSet = chooseQuestions(currentSet)
print("Got "..#currentSet.." questions in current set "..chosenSet)
teleportPlayer(player, -9.3, 54.99, -461.5)
for i, v in pairs(out) do if (v:lower() == player.Name:lower()) then table.remove(out, i)end end
table.insert(playing, player.Name)
wait(3)
gui.Frame1.TextBox.Text = "There are "..#currentSet.." questions in the "..chosenSet.." set!"
wait(3)
gui.Frame1.TextBox.Text = sets[chosenSet].Reward.." Bronze Coins will be awarded to the winners per round."
wait(3)
for i = 1, index do
gui.Frame1.TextBox.Text = "Question "..i.."!"
wait(3)
ask(currentSet[i])
end
print("Finishing game.")
gui.Frame1.TextBox.Text = "Game Over!"
wait(3)
gui.Frame1.TextBox.Text = "The winner(s) are : "..table.concat(playing, ", ").."! Congratulations!"
wait(3)
gui.Frame1.TextBox.Text = "The winner(s) are being awarded "..sets[chosenSet].Reward.." Bronze Coins."
award(playing)
intermission()
end
end
end
while wait() do
repeat wait(.1) until #game.Players:GetPlayers() > 0
run()
end |
|
ked2000Join Date: 2011-07-10 Post Count: 1059 |
Thanks! |
|