Hey!
I’m making this game where one player is chosen to have a bomb, and has to pass it around, and the player who owns the bomb at the last minute will die, and if theres more than 1 person, the game continues until one person is left, and he/she wins the game.
I already made a script which does this, but I need help on how to add more rounds, and stop it when only one person is left.
Here’s the script:
-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
-- game things
local plrstable = {}
local tagtable = {}
local spawnpoint = workspace.SpawnPoint
local Status = ReplicatedStorage:WaitForChild("Value")
local gametime = 180
local InRound = Instance.new("BoolValue")
InRound.Name = "InRound"
local IsTagger = Instance.new("BoolValue")
IsTagger.Name = "IsTagger"
local BombTool = ServerStorage:WaitForChild("Tag")
game.Players.PlayerAdded:Connect(function(player)
local IsTaggerClone = IsTagger:Clone()
local InRoundClone = InRound:Clone()
InRoundClone.Parent = player
IsTaggerClone.Parent = player
end)
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
if player.InRound.Value == true then
player.InRound.Value = false
local find = table.find(plrstable, player.UserId)
if find then
plrstable[find] = nil
print(player.Name.." died, removed from table")
end
end
end)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local find = table.find(plrstable, player.UserId)
if find then
plrstable[find] = nil
print(player.Name.." left server, removed from table")
end
end)
while true do
local intermission = 60
Status.Value = "Waiting for two or more players to join..."
repeat wait(1) until #game.Players:GetPlayers() >= 2
repeat
intermission -= 1
Status.Value = "Intermission: "..intermission
wait(1)
until intermission == 0
Status.Value = "Only map lol, let's goo!"
for i, v in pairs(game.Players:GetPlayers()) do
if v then
table.insert(plrstable, v.UserId)
print(plrstable)
v.InRound.Value = true
end
local character = v.Character
character.HumanoidRootPart.Position = spawnpoint.Position
end
intermission = 20
repeat
wait(1)
intermission -= 1
Status.Value = "First round starting in "..intermission
until intermission == 0
local Players = game.Players:GetPlayers()
local randomPlayer = Players[math.random(#Players)]
if randomPlayer.InRound.Value == true then
Status.Value = randomPlayer.Name.." is da bomber"
randomPlayer.IsTagger.Value = true
local bombclone = BombTool:Clone()
bombclone.Parent = randomPlayer.Character
end
intermission = 120
repeat
wait(1)
intermission -= 1
Status.Value = "Time left "..intermission
until intermission == 0
wait(1)
for i, v in pairs(game.Players:GetPlayers()) do
if v.InRound.Value == true then
if v.IsTagger.Value == true then
v.Character.Humanoid:TakeDamage(100)
end
end
end
wait(1)
Status.Value = "Round over!"
wait(5)
for i, v in pairs(plrstable) do
if #v <= 1 then
Status.Value = v.Name.." won the game!"
end
end
end
Help is appreciated, thanks!