Round system only starts running disaster functions when the player is eliminated?

I’ve got a round system script which calls module functions depending on the game mode. There have been very little issues with it’s functionality, except the fact that the disasters only start when I get eliminated, aka, when the collection service tag on the eliminated player changes from:

Alive

to

Dead

I don’t understand why this is happening, and it isn’t meant to function this way anyway. The idea was it would repeatedly run a function until either of the 2 conditionals are met. I would really appreciate support on this!

Game Code (Snippet)

while true do
	local isReady = CheckPlayers()
	if isReady then
		game.ReplicatedStorage.Regenerating.Value = true
		local chosenMode = chooseMode()
		setMap(chosenMode)
		local spleefMap = workspace:WaitForChild("SpleefMap")
		print("Enough Players")
		game.ReplicatedStorage.Regenerating.Value = false

		ReplicatedStorage.IsIntermission.Value = true
		for i = 30, 0, -1 do
			Intermission.Value = i
			wait(1)
		end
		local configurationTable = {
			["Classic"] = function()
				TeleportPlayers()
				repeat 
					selectDisasters()
					wait(5)
				until roundTime.Value == 0 or #CollectionService:GetTagged("Alive") == 0
			end,
			["Chess Chaos"] = function()
				TeleportPlayers()
				repeat
					disasterModule.Chess()
					wait(5)
				until roundTime.Value == 0 or #CollectionService:GetTagged("Alive") == 0
			end,
			["Colour Elimination"] = function()
				local randomRGBTable = {
					BrickColor.Red(),
					BrickColor.Green(),
					BrickColor.Blue()
				}
				TeleportPlayers()
				repeat
					selectDisasters()
					local TextLabel = workspace:FindFirstChild("Current"):FindFirstChild("Part"):FindFirstChild("SurfaceGui"):FindFirstChild("TextLabel")
					local rnd = randomRGBTable[math.random(1,#randomRGBTable)]
					for i = 1, 15 do
						selectDisasters()
						if rnd == BrickColor.Red() then
							TextLabel.Text = "Getting Rid Of Red"
						elseif rnd == BrickColor.Blue() then
							TextLabel.Text = "Getting Rid Of Blue"
						else
							TextLabel.Text = "Getting Rid Of Green"
						end
						local tile
						repeat
							tile = spleefMap:GetDescendants()[math.random(1,#spleefMap:GetDescendants())]
							wait()
						until tile:IsA("Part") and  tile.BrickColor == rnd
						if tile.BrickColor == rnd then
							local explosion = Instance.new("Explosion")
							explosion.Parent = tile
							explosion.Position = tile.Position + Vector3.new(0,1,0)
							wait(1)
							explosion:Destroy()
							tile:Destroy()
						end
						wait(1)
					end
					for i = 10,0, -1 do
						TextLabel.Text = "Cooldown ("..i.."). Get Ready"
						wait(1)
					end
				until roundTime.Value == 0 or #CollectionService:GetTagged("Alive") == 0
			end,
			
			["Zapper"] = function()
				TeleportPlayers()
				repeat
					disasterModule.Zap()
					wait(5)
				until roundTime.Value == 0 or #CollectionService:GetTagged("Alive") == 0
			end,

		}
		if Intermission.Value == 0 then
			for i, v in pairs(game.Players:GetPlayers()) do
				CollectionService:AddTag(v, "Alive")
			end
			ReplicatedStorage.IsIntermission.Value = false
			game.ReplicatedStorage.StartPowerups:FireAllClients(true)
			print("Starting")
		
			configurationTable[chosenMode]()
			for i = 120, 0, -1 do
				if roundTime.Value == 0 or #CollectionService:GetTagged("Alive") == 0  then
					break
				end
				wait(1)
			end
		end

Where does the code stop if I may ask? It’s probably an issue with the execution if I had to assume. You may need a few more print statements for debugging

I’ll start adding some prints and I’ll update you on where it may be yielding

1 Like

Sorry for the delay @EmbatTheHybrid, I took your steps and successfully managed to get it functioning correctly! I’ll keep tips like these in mind next time something similiar happens

1 Like

I recommend you explain what you did to fix it in case someone else has an issue similar to what you have, it’s not required, but would help out others in the future!

It turns out it wasn’t to do with the actual section of code itself, but the module which held all the functions for the disasters. I messed up some of the code within one of those and it all fixed itself once I re-coded it. Thanks anyway!

1 Like