Lately, I have been working on a sword fight game. Though a line doesn't work and i am confused, any help would be appreciated.
Code:
--Defining variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local MapsFolder = ServerStorage:WaitForChild("Maps")
local Status = ReplicatedStorage:WaitForChild("Status")
local GameLenght = 50
local reward = 50
--game loop
while true do Status.Value = "Waiting for Players."
repeat wait(1) until game.Players.NumPlayers >= 2
Status.Value = "Intermission"
wait(10)
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player) --add each player into plrs table
end
end
wait(2)
local AvailableMaps = MapsFolder:GetChildren()
local ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
Status.Value = ChosenMap.Name.." Chosen!"
local ClonedMap = ChosenMap:Clone()
ClonedMap.Parent = workspace
--Teleport Players
local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
if not SpawnPoints then
print("no")
end
local AvailableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs(plrs) do
if player then
character = player.Character
if character then
--tp
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame
table.remove(AvailableSpawnPoints,1)
--sword giving!
local sword = ServerStorage.ClassicSword:Clone()
sword.Parent = player.Backpack
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
--no char
if not player then
table.remove(plrs,i)
end
end
end
end
Status.Value = "Get Ready TO BRAWL!"
wait(2)
for i = GameLenght,0,-1 do
for x, player in pairs(plrs) do
if player then
character = player.Character
if not character then
--left game
else
if character:FindFirstChild("GameTag") then
print(player.Name.." is still here. he/she has potential.")
else
--ded
table.remove(plrs,x)
print(player.Name.." Has been removed")
end
end
else
table.remove(plrs,x)
print(player.Name.." Has been removed")
end
end
end
Status.Value = "There are "..i.." Seconds remaining, and "..#plrs.." players are left"
if #plrs == 1 then
Status.Value = "THE WINNER IS... "..plrs[1].Name
plrs[1].leaderstats.Bucks.Value = plrs[1].leaderstats.Bucks.Value + reward
break
elseif #plrs == 0 then
Status.Value = "EASTER EGG! HAHA!"
break
elseif i == 0 then
Status.Value = "Time's up. nobody won"
end
print("End of game")
for i, player in pairs(game.Players:GetPlayers()) do
character = player.Character
if not character then
--ignore
else
if character:FindFirstChild("GameTag") then
character.GameTag:Destroy()
end
if player.Backpack:FindFirstChild("ClassicSword") then
player.Backpack.ClassicSword:Destroy()
end
if character:FindFirstChild("ClassicSword") then
character.ClassicSword:Destroy()
end
end
player:LoadCharacter()
end
ClonedMap:Destroy()
Status.Value = "Game...Ended."
end
it says that the "i" at the "there are ..i.. seconds remaining is wrong. any help to debug that?

4 comments
Help would be needed.
You are trying to modify the Status.Value AFTER you ended your loop. Move that line inbtween the ends on line 89 and 90
It worked, thank you, but there is the same problem (I think) at line 101. I have no idea where to put it though.
Nevermind.