So I made a mini game script that works well, but the problem is, I do not know how to add a countdown timer. Because both players (f1, and f2) could be moving around not shooting nothing each other then game will never end, basically if a player dies or a player leaves, then the other player would get the victory and the game would end. Didn't want to put whole script having you look line to lines, so I added the main part. Usually the game does not end until someone dies or someone leaves, but I want to add a timer to end the game once it hits 0. Appreciate it!
--Script by Apex
Spawn1 = Vector3.new(-18.9, 6.91, -12.669) -- where to spawn Stone cold
Spawn2 = Vector3.new(-18.9, 6.91, 20.814) -- where to spawn Kane
mTime = 3 -- ammount of time for messages to appear
winner = nil
stat = "wins" -- name of the leaderstat to add points too
points = 1 --the number to give to the above stat ^
intermission = true -- if you don't want an intermission then set to false
interTime = 30-- the intermission length if you have one
SS = game:GetService("Lighting")
local weapons = game.ServerStorage.Weapons:GetChildren()
---------------------------------------------------------------------
local Players = game:GetService("Players")
local replicatedstorage = game:GetService("ReplicatedStorage")
local m = replicatedstorage:WaitForChild('InfoValue')
local l = game.ServerStorage
workspace.Int2:Play()
while wait() do
repeat
wait()
m.Value = "2 or more players needed to start."
until game.Players.NumPlayers >=2
local m = replicatedstorage:WaitForChild('InfoValue')
repeat
wait()
m.Value = "2 or more players needed to start."
until game.Players.NumPlayers >=2
if intermission then
workspace.Int2:Stop()
wait(0.1)
workspace.Music:Play()
for i = interTime,1,-1 do
m.Value = "Intermission - "..i
end
end
m.Value = "Choosing a random player..."
wait(mTime)
local pl = game.Players:GetPlayers()
for i = 30,1,-1 do
wait(i*0.04)
m.Value = pl[math.random(1,#pl)].Name.." vs "..pl[math.random(1,#pl)].Name
end
f1 = pl[math.random(1,#pl)]
repeat wait() -- avoid the same player fighting themself :P
f2 = pl[math.random(1,#pl)]
until f2 ~= f1
wait(mTime)
m.Value = f1.Name.." VS "..f2.Name.."!"
wait(0.1)
f1.PlayerGui.SpectateGui:Destroy()
wait(0.1)
f2.PlayerGui.SpectateGui:Destroy()
wait(mTime)
m.Value = "GET READY! KNIFE FIGHT"
wait(mTime)
m.Value = "Spawning players..."
wait(1)
f1.Character.Humanoid.WalkSpeed = 0
wait(0.1)
f1.Character.Humanoid.Jump = true
wait(0.3)
f1.Character:MoveTo(Spawn1)
wait(1)
f2.Character.Humanoid.WalkSpeed = 0
wait(0.1)
f1.Character.Humanoid.Jump = true
wait(0.3)
f2.Character:MoveTo(Spawn2)
wait(1)
workspace.Music:Stop()
workspace.St:Play()
game.ServerStorage.Sto:Clone().Parent = game.Workspace
for i,v in pairs(game.Players:GetPlayers()) do
local cs1 = SS.CutsceneScript3:Clone()
v:WaitForChild("Backpack")
cs1.Parent = v.Backpack
cs1.Disabled = false
end
wait(14)
workspace.St:Stop()
m.Value = "Let's start the introduction.."
wait(4.4)
m.Value = "Ladies and Gentleman! Make some noise for "..f1.Name.."!!"
wait(0.2)
for i,v in pairs(game.Players:GetPlayers()) do
local cs1 = SS.CutsceneScript:Clone()
v:WaitForChild("Backpack")
cs1.Parent = v.Backpack
cs1.Disabled = false
end
wait(0.1)
game.Workspace.Crowd:Play()
wait(5.1)
game.Workspace.Crowd:Stop()
wait(2)
m.Value = "Ladies and Gentleman! Make some noise for "..f2.Name.."!!"
wait(0.2)
for i,v in pairs(game.Players:GetPlayers()) do
local cs1 = SS.CutsceneScript1:Clone()
v:WaitForChild("Backpack")
cs1.Parent = v.Backpack
cs1.Disabled = false
end
wait(0.1)
game.Workspace.Crowd:Play()
wait(5.1)
game.Workspace.Crowd:Stop()
wait(2)
m.Value = f1.Name.." and "..f2.Name.." you better get to know each other before yall fight..."
wait(3)
workspace.Int:Play()
wait(20)
m.Value = "TIP: Take your time shooting and use it wisely, so that you do not run out of ammo."
workspace.Int:Stop()
wait(3)
game.Workspace.Buzz:Play()
m.Value = "3"
wait(1)
game.Workspace.Buzz:Play()
m.Value = "2"
wait(1)
game.Workspace.Buzz:Play()
m.Value = "1"
wait(1)
game.Workspace.Go:Play()
workspace.Sto:Destroy()
m.Value = "FIGHT!!!"
wait(1)
f1.Character:MoveTo(Vector3.new(-155.5, 6.91, -125.2))
wait(0.1)
f2.Character:MoveTo(Vector3.new(109.8, 6.91, 137.502))
wait(0.1)
local random = weapons[math.random(1, #weapons)]
random:Clone().Parent = f1.Backpack
l["Smoke Grenade"]:Clone().Parent = f1.Backpack
wait(0.1)
random:Clone().Parent = f2.Backpack
l["Smoke Grenade"]:Clone().Parent = f2.Backpack
f1.Character.Humanoid.MaxHealth = 300
f1.Character.Humanoid.Health = 300
f1.Character.Humanoid.WalkSpeed = 16
wait(0.1)
f2.Character.Humanoid.MaxHealth = 300
f2.Character.Humanoid.Health = 300
f2.Character.Humanoid.WalkSpeed = 16
repeat
wait()
if not Players:FindFirstChild(f1.Name) or (f1.Character.Humanoid.Health <= 0) then
winner = f2
elseif not Players:FindFirstChild(f2.Name) or (f2.Character.Humanoid.Health <= 0) then
winner = f1
end
until winner ~= nil
if winner:findFirstChild("leaderstats") then
if winner.leaderstats:findFirstChild(stat) then
winner.leaderstats[stat].Value = winner.leaderstats[stat].Value + 1
end
end
m.Value = "The winner is... "..winner.Name.."!"
wait(1)
game.Workspace.Crowd1:Play()
wait(10)
game.Workspace.Crowd1:Stop()
wait(1)
winner.Character:BreakJoints()
winner = nil
end

5 comments
You're using deprecated code, makes it feel like none of this code is even yours. Why did you use FindFirstChild correctly in lines 3 and line 6 and stopped at line 10? And why are you wrapping your if statements in parentheses, like in lines 3 and line 6? They are exclusively for math.
That's because that's not the whole script.
Let me put in the whole script so you can understand then.
That's because I needed help with if a player leaves, so a random dude helped me on this and suggested I use findFirstchild
This is the link to the answer the guy gave me https://scriptinghelpers.org/questions/59014/player-leaves-game-ends-up-breaking