Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Round System Problems? - @TheDeadlyPanther or anyone else.

Asked by 9 years ago

So earlier I asked a question about my round system code saying that it isn't functional. Later on I got at least 2 responses about it, but it's still not working.

I was wondering if someone could check my code and see if there is a way to fix it. Thank you if you do! (If you can, please also show me a where I fix the code in Lua.)

001function playerNotification(Text)
002    for _,v in pairs (game.Players:GetChildren()) do
003        local textLabel = v.PlayerGui:FindFirstChild("ScreenGui")
004        if textLabel then
005            textLabel.Frame.TextLabel.Text = Text
006        end
007    end
008end
009 
010function waitForPlayers()
011    while game.Players.NumPlayers < 2 do
012        playerNotification("You need 1 more player to start the game.")
013    end
014end
015 
View all 113 lines...
0
You aren't providing the point where the script errors. Also, if you ask a question in this way, everyone is open to answer - don't mention specific ones. Marios2 360 — 9y

1 answer

Log in to vote
0
Answered by
M39a9am3R 3210 Moderation Voter Community Moderator
9 years ago

In your intermissionTimer function, you're missing an end. There should be one for the end of the for loop.

1function intermissionTimer()
2    if game.Players.NumPlayers > 2 then
3    for countDown = 10, 1, -1 do
4        playerNotification("Intermission: " ..countDown)   
5    end
6end

However, the reason your script isn't throwing an error is because you the end for the if then statement on the intermissionTimer is acting as a end for the for loop. As well as the end intended for ending the function, is ending the if then statement. What this means is all the way at line 113 is the end of the intermissionTimer function. Since intermissionTimer is not being called, nothing can be done in the while loop, thus your script goes inactive just holding functions waiting to be used.

How to fix this, you need to remove the end from line 112, and add an end at line 20. So now your intermissionTimer function should look like this,

1function intermissionTimer()
2    if game.Players.NumPlayers > 2 then
3    for countDown = 10, 1, -1 do
4        playerNotification("Intermission: " ..countDown)   
5    end
6    end
7end
If this helped, leave an upvote and if it worked hit the accept answer button! Leave a comment if you have any other questions or need further explanation somewhere.
Ad

Answer this question