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

Problems with Round Script ending properly?

Asked by 6 years ago
Edited 6 years ago

Hello!

Problem: When Team 1 wins, the match results display that they won, but the countdown is still going on.

How can I correct this?

-- Round information
for i = 90, 0, -1 do
    if i == 0 then print('Test1')

        status.Value = 'Time Up! No Winner!'
        break   
    else end -- End for Line 84 
     wait(1)
local maxscore = 2
local team1 = game.Teams.Wizards
local team2 = game.Teams.Warlocks
local PlayersT1 = team1:GetPlayers()
local PlayersT2 = team2:GetPlayers()    
        print("Test2")

    if wizardscore.Value >= maxscore then
        for i, plr in pairs(team1:GetPlayers()) do
            status.Value = 'Team Wizards is the Winner!' print("Test3") 
            wait(1)
                PlayersT1[i].leaderstats.Coins.Value = PlayersT1[i].leaderstats.Coins.Value +5
                PlayersT1[i].leaderstats.Experience.Value = PlayersT1[i].leaderstats.Experience.Value + 10
                PlayersT1[i].leaderstats.Wins.Value = PlayersT1[i].leaderstats.Wins.Value +1
        end -- End for line 97 

                    print("Test4")  
    elseif warlockscore.Value >= maxscore  then
        for i, plr in pairs(team2:GetPlayers()) do
            status.Value = 'Team Warlocks is the winner!'  print("Test5")   
            wait(1)
                PlayersT2[i].leaderstats.Coins.Value = PlayersT2[i].leaderstats.Coins.Value +5
                PlayersT2[i].leaderstats.Experience.Value = PlayersT2[i].leaderstats.Experience.Value + 10
                PlayersT2[i].leaderstats.Wins.Value = PlayersT2[i].leaderstats.Wins.Value +1
        end -- End for Line 106  
                print("Test6")  


        break
    else end -- End for Line 96
        status.Value = i..' seconds remaining!'   print("Test7")    
end -- End for Line 83
mapstorage:ClearAllChildren()  print("Test8")   
wizardscore.Value = 0 print("Test9")    
warlockscore.Value = 0  print("Test10") 

end -- End for Line 13/While True Do
        print("Test11") 

1
replace break with return abnotaddable 920 — 6y
0
Thanks for the response! I have two "break"s in my script, so I tried all three combinations of replacing one of them, but not the other, then replaced the opposite, then replaced both, but the same problem occurred. Never2Humble 90 — 6y
0
I replaced the >= with == for Line 16 and Line 25, which does solve the countdown problem, but still only gives the leaderstat points to Team 1. I'm gonna feel real stupid when you tell me what >= should be replaced with. x.x Never2Humble 90 — 6y
0
^ Updated the script, but the countdown still keeps going after the winner is declared, but it does do the leaderstat awards bumps. Never2Humble 90 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Problem was solved. :) Just needed to add one more break in the loop above Line 23. Thank you to abnotaddable as always!

Ad

Answer this question