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

When changing the boolvalue game round won't end?

I have this part of my game script when the bool value turns true then the game should stop but then when I change it to true in server storage when testing it in studio the round will not end. Can you help?

	for _,player in pairs(Game.Players:GetChildren()) do
				local Gui = player.PlayerGui.Gui
				Gui.Label.Text = LocationMsg
				repeat
				    wait(1)
				   GameTime = GameTime - 1
				     Gui.Label.Text = "Game time: "..GameTime
				    
				  until  GameTime  == 0 or IsBombDisarmed == true
				  if IsBombDisarmed == true then
				     Gui.Label.Text = WinMsg
				     for _, player in pairs(Game.Players:GetChildren()) do
				        local Gui = player.PlayerGui.Gui
				        Gui.Label.Text = WinMsg
				        player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + WinningAmount
				        wait(2)
				        GameTime = RestoreGameTimeAmmount
			            break
			            end
		           elseif GameTime == 0 then
		               
		                for _, player in pairs(Game.Players:GetChildren()) do
				        local Gui = player.PlayerGui.Gui
				        Gui.TextLabel.Text = LoseMsg
				        wait(2)
				        GameTime = RestoreGameTimeAmmount
				        break
				            
	                    end
			        end
				end      
			end	 
		end

1 comment

0

Maybe try putting it in a loop, like a repeat until the value is turned to true

1 answer

✓ Accepted answer

IsBombDisarmed will not change value unless an event connected to the BoolValue itself redefines the variable. The more straightforward thing to do would be to just read the value.

2 comments

0

IsBombDisarmed is not the value, it is a variable set to the value of the value and it is set once. IsBombDisarmed does not change.

0

Thanks I didn't realize that I didn't have .Value.

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