Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Problems with Round Script ending properly?

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")	

4 comments

1

replace break with return

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.

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

0

^ Updated the script, but the countdown still keeps going after the winner is declared, but it does do the leaderstat awards bumps.

1 answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.