Hello developers!
I want each round to not ignore the winner from the previous sword fight round in the current sword fight round. When there are 2 players left to sword fight, the previous winner won’t get picked which will cause the script to exhaust and stop it.
Here is a script to help you better understand. Look at the previous scripting support topic to understand more.
while true do
local Status = game.ReplicatedStorage:WaitForChild("Status")
local BCG = game.ReplicatedStorage:WaitForChild("BrickColorGui")
repeat
wait(0.01)
local playerTable = #game.Players:GetPlayers()
game.StarterGui.TalkGui.TalkFrame.TalkText.Text = "Waiting for 8 players... There are "..playerTable.." players in this server!"
until
playerTable >= 1
local playerTable = #game.Players:GetPlayers()
if playerTable >= 1 then
Status.Value = "Starting..." -- change the values to what you want it to say
wait(3)
Status.Value = "Welcome to Endurance v2!"
wait(4)
Status.Value = "This is a game based off the original Endurance game made by Endurance ©."
wait(4)
Status.Value = "The rules of playing this game are very simple."
wait(3.5)
Status.Value = "You have to choose your brick color, race on challenges, Random Players except winner will be picked. Fight to death."
wait(10)
Status.Value = "This process repeats until 2 players remain! They fight to death until they run out of bricks."
wait(8)
Status.Value = "You may choose your brick color."
wait(4)
BCG.Value = true
wait(10)
BCG.Value = false
Status.Value = "We may now start this round of Endurance v2, Good Luck!"
local interVal = 20
repeat wait(1)
interVal -= 1
Status.Value = "Intermission: "..interVal
until
interVal <= 0
local maps = game.Lighting.Maps:GetChildren()
local randomMap = maps[math.random(1, #maps)]
local map = randomMap:Clone()
map.Parent = workspace
wait(2)
local randomBlockWorth = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
local BlockWorth = randomBlockWorth[math.random(1, #randomBlockWorth)]
Status.Value = "This minigame is worth "..BlockWorth.." blocks!"
wait(4)
Status.Value = "This minigame we are playing today is..."
wait(4)
Status.Value = map.Name.."!"
game.ReplicatedStorage:WaitForChild("Minigame").Value = map.Name
wait(3)
Status.Value = "Good luck!"
wait(3)
local players = game.Players:GetPlayers()
for i,v in pairs(players) do -- teleport all the players inside the playing team since we removed all the ones who aren't in the playing team
if v:IsA("Player") then
if v.Team == game.Teams:WaitForChild("Playing") then
local Char = v.Character
v.Team = game.Teams.Alive
Char:PivotTo(map:WaitForChild("TeleportToMinigame").CFrame) -- put the spawn's CFrame between the pivotTo's brackets.
end
end
end
wait(3)
if game.ReplicatedStorage:WaitForChild("Minigame").Value == "Last to Leave Island" then
Status.Value = "Welcome to Last to Leave Island!"
wait(4)
Status.Value = "In this minigame, you have to fight on an island with your sword."
wait(6)
Status.Value = "Fight your opponent and the loser will be eliminated."
wait(5)
Status.Value = "The winner will have to fight the next winner."
wait(4)
Status.Value = "Earthworm Sally/Mayor of the Island will pick the random players."
wait(8)
Status.Value = "Good Luck!"
wait(4)
local pickedPlayers = {}
repeat
Status.Value = "Mayor: I am the great Mayor of this island!"
wait(5)
Status.Value = "Mayor: I choose to pick the following to fight..."
wait(5)
local playerTableforAliveTeam = game.Teams.Alive:GetPlayers()
local rPlayer1
repeat
rPlayer1 = playerTableforAliveTeam[math.random(1, #playerTableforAliveTeam)]
until not table.find(pickedPlayers, rPlayer1)
table.insert(pickedPlayers, rPlayer1)
Status.Value = "Mayor: "..rPlayer1.Name.." VS..."
rPlayer1.Character.Humanoid.WalkSpeed = 0
game.ServerStorage.ClassicSword:Clone().Parent = rPlayer1.Backpack
rPlayer1.Character:MoveTo(map.Red.Position + Vector3.new(0,3,0))
rPlayer1.Team = game.Teams.Red
task.wait(5)
local rPlayer2
repeat
rPlayer2 = playerTableforAliveTeam[math.random(1, #playerTableforAliveTeam)]
until not table.find(pickedPlayers, rPlayer2)
table.insert(pickedPlayers, rPlayer2)
Status.Value = "Mayor: "..rPlayer2.Name.."!"
rPlayer2.Character.Humanoid.WalkSpeed = 0
game.ServerStorage.ClassicSword:Clone().Parent = rPlayer2.Backpack
rPlayer2.Character:MoveTo(map.Blue.Position + Vector3.new(0,3,0))
rPlayer2.Team = game.Teams.Blue
wait(3)
Status.Value = "Mayor: Good Luck!"
wait(2)
Status.Value = ""
rPlayer1.Character.Humanoid.WalkSpeed = 16
rPlayer2.Character.Humanoid.WalkSpeed = 16
repeat
wait(0.01)
until
rPlayer1.KilledValue.Value == true or rPlayer2.KilledValue.Value == true
if rPlayer1.KilledValue.Value == true then
Status.Value = "Mayor: "..rPlayer1.Name.."has won the fight!"
rPlayer1.KilledValue.Value = false
rPlayer2.Team = game.Teams.Alive
rPlayer1.Team = game.Teams.Playing
rPlayer1.Character.Humanoid.Health = 0
wait(4)
end
if rPlayer2.KilledValue.Value == true then
Status.Value = "Mayor: "..rPlayer2.Name.."has won the fight!"
rPlayer2.KilledValue.Value = false
rPlayer1.Team = game.Teams.Alive
rPlayer2.Team = game.Teams.Playing
rPlayer2.Character.Humanoid.Health = 0
wait(4)
end
until
#game.Teams.Alive:GetPlayers() == 2
if #game.Teams.Alive:GetPlayers() == 2 then
Status.Value = "Mayor: The final 2 players shall fight to death"
wait(5)
local playerTableforAliveTeam = game.Teams.Alive:GetPlayers()
local rPlayer1
repeat
rPlayer1 = playerTableforAliveTeam[math.random(1, #playerTableforAliveTeam)]
until not table.find(pickedPlayers, rPlayer1)
table.insert(pickedPlayers, rPlayer1)
Status.Value = "Mayor: "..rPlayer1.Name.." VS..."
rPlayer1.Character.Humanoid.WalkSpeed = 0
game.ServerStorage.ClassicSword:Clone().Parent = rPlayer1.Backpack
rPlayer1.Character:MoveTo(map.Red.Position + Vector3.new(0,3,0))
rPlayer1.Team = game.Teams.Red
task.wait(5)
local rPlayer2
repeat
rPlayer2 = playerTableforAliveTeam[math.random(1, #playerTableforAliveTeam)]
until not table.find(pickedPlayers, rPlayer2)
table.insert(pickedPlayers, rPlayer2)
Status.Value = "Mayor: "..rPlayer2.Name.."!"
rPlayer2.Character.Humanoid.WalkSpeed = 0
game.ServerStorage.ClassicSword:Clone().Parent = rPlayer2.Backpack
rPlayer2.Character:MoveTo(map.Blue.Position + Vector3.new(0,3,0))
rPlayer2.Team = game.Teams.Blue
wait(3)
Status.Value = "Mayor: Good Luck!"
wait(2)
Status.Value = ""
rPlayer1.Character.Humanoid.WalkSpeed = 16
rPlayer2.Character.Humanoid.WalkSpeed = 16
repeat
wait(0.01)
until
rPlayer1.KilledValue.Value == true or rPlayer2.KilledValue.Value == true
if rPlayer1.KilledValue.Value == true then
Status.Value = "Mayor: "..rPlayer1.Name.." is the winner of this minigame!"
rPlayer1.KilledValue.Value = false
rPlayer2.Team = game.Teams.Alive
rPlayer1.Team = game.Teams.Playing
rPlayer1.Character.Humanoid.Health = 0
rPlayer2.Character.Humanoid.Health = 0
rPlayer1.WinnerOfMinigame.Value = true
wait(4)
end
if rPlayer2.KilledValue.Value == true then
Status.Value = "Mayor: "..rPlayer2.Name.." is the winner of this minigame!"
rPlayer2.KilledValue.Value = false
rPlayer1.Team = game.Teams.Alive
rPlayer2.Team = game.Teams.Playing
rPlayer2.Character.Humanoid.Health = 0
rPlayer1.Character.Humanoid.Health = 0
rPlayer2.WinnerOfMinigame.Value = true
wait(4)
end
end
end
end
end
Thanks!