Round system help

  1. What do you want to achieve? When the round starts, a bomb is given to a random person, and after 20 seconds, the person holding the bomb explodes, and another random person gets the bomb. I hope this repeats until there is only one person left alive.

  2. What is the issue? When the round starts, one person explodes and the bomb goes to the other person. Instead, one person explodes and the bomb continues to explode after that.

  3. What solutions have you tried so far? I searched the forums but couldn’t find a solution

I’m making a game about passing bombs with 5 friends, and when the round starts, the person holding the bomb explodes, and instead of the other person getting the bomb, if the person holding the bomb explodes, the explosion continues even if that person dies. Below is the round start script.

local currentBombTarget = game.ReplicatedStorage.CurrentBombTarget
local currentMapModel = nil
local alive = {}

local function placePlayer(plr, position)
	plr.Character:PivotTo(position * CFrame.new(0, 3, 0))
end

local function randomPlayerBombTarget(plrs)
	local random = math.random(1, #plrs)
	
	currentBombTarget.Value = plrs[random]
	
	local target = currentBombTarget.Value.Character
	
	target.Humanoid.WalkSpeed += 2
	
	target:WaitForChild("Bomb").Value = true
	local bomb = game.ReplicatedStorage.Assets.TimeBomb:Clone()
	bomb.Parent = target
	bomb:PivotTo(target.PrimaryPart.CFrame)
	local M6D = game.ReplicatedStorage.Assets.Base:Clone()
	M6D.Parent = target:WaitForChild("Torso")
	M6D.Part0 = target:WaitForChild("Torso")
	M6D.Part1 = bomb.Base
end

local function randomMapVote(map)
	
end

local function randomMap(mapsFolder)
	local mapList = mapsFolder:GetChildren()
	local map:Folder = mapList[math.random(1, #mapList)]
	
	for i, model in map:GetChildren() do
		if model:IsA("Model") then
			local clone = model:Clone()
			clone.Parent = workspace
			currentMapModel = clone
			clone:PivotTo(workspace.MapAnchorPosition.CFrame)
		end
	end
end

local function boom(plr:Player)
	local boomVFX = game.ReplicatedStorage.Assets.Boom:Clone()
	boomVFX.Parent = workspace
	boomVFX:PivotTo(plr.Character:GetPivot())
	game.Debris:AddItem(boomVFX, 5)
	
	plr.Character.Humanoid.Health = 0
	boomVFX.Light.Brightness = 25
	boomVFX.Light.Range = 0
	boomVFX.Explosion:Play()
	game.TweenService:Create(
		boomVFX.Light, 
		TweenInfo.new(3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), 
		{Range = 25}
	):Play()
	game.TweenService:Create(
		boomVFX.Light, 
		TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), 
		{Brightness = 0}
	):Play()
	boomVFX.Smoke:Emit(3)
	task.wait()
	boomVFX.Smoke:Emit(5)
	boomVFX.Attachment.Smoke:Emit(5)
	task.wait()
	boomVFX.Smoke:Emit(7)
	boomVFX.Attachment.Smoke:Emit(5)
	boomVFX.Attachment.Fire:Emit(1)
	task.wait()
	boomVFX.Attachment.Smoke:Emit(5)
	task.wait()
	boomVFX.Attachment.Smoke:Emit(5)
end

local function roundStart()
	local players = game.Players:GetPlayers()
	if #players < 2 then
		return
	end
	
	game.ReplicatedStorage.Game.Value = true
	randomPlayerBombTarget(players)
	randomMap(workspace.Maps)
	for i, plr in players do
		if plr.Character then
			if plr.Character.Bomb.Value == true then
				placePlayer(plr, currentMapModel.Player2Spawn.CFrame)
			else
				placePlayer(plr,currentMapModel.Player1Spawn.CFrame)
			end
		end
	end
	
	for i, plr in players do
		if plr.Character then
			table.insert(alive, plr)
		end
	end
	--while true do
	--	task.wait()
	--	if #alive == 1 then
	--		break
	--	end
	--	boom(currentBombTarget.Value)
	--end
	
	repeat task.wait()
		task.wait(20)
		boom(currentBombTarget.Value)
	until #alive == 1
	
	game.ReplicatedStorage.Game.Value = false
	currentBombTarget.Value = nil
	table.clear(alive)
	currentMapModel:Destroy()
	for i, plr in alive do
		plr.Character:Pivot(CFrame.new(20.75, 11.75, -20.25))
	end
end

game.Players.PlayerRemoving:Connect(function(plr)
	table.remove(alive, table.find(alive, plr))
end)

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local split = string.split(msg, " ")
		if split[1] == "#start" then
			if game.ReplicatedStorage.Game.Value == false then
				roundStart()
			end
		end
	end)
	
	plr.CharacterAdded:Connect(function(char)
		char.Humanoid.Died:Connect(function()
			char.Lobby.Value = true
			table.remove(alive, table.find(alive, plr))
		end)
	end)
end)

:cry: :cry: :cry:

You aren’t assigning a new bomb target, try something like this.

repeat task.wait()
task.wait(20)
boom(currentBombTarget.Value)
randomPlayerBombTarget(plrs)
until #alive == 1

It was resolved, but one person remains and the map is not deleted, and even people in the lobby receive bombs.