I have followed alvinbloxs game video and my game keeps looping and not waiting 100 seconds! please help
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local Maps = SS:WaitForChild("Maps")
local Status = RS:WaitForChild("Status")
local GameLength = 100
local reward = 50
local money = game.Players.LocalPlayer
-- Game Loop
while true do
Status.Value = "Waiting for enough players!"
repeat wait(1) until game.Players.NumPlayers >= 2
Status.Value = "Waiting for game to start..."
wait(8)
local PlayerTable = {}
for i, player in pairs (game.Players:GetPlayers()) do
if player then
table.insert(PlayerTable,player) -- add player into players table
end
end
wait(2)
local UsableMaps = Maps:GetChildren()
local ChosenMap = UsableMaps[math.random(1,#UsableMaps)]
Status.Value = ChosenMap.Name.." has been chosen"
local MapSpawned = ChosenMap:Clone()
MapSpawned.Parent = workspace
local SpawnPoints = MapSpawned:FindFirstChild("SpawnPoints")
if not SpawnPoints then
print("Not Found Spawnpoints..")
end
local UsableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs (PlayerTable) do
if player then
character = player.Character
if character then
character:FindFirstChild("HumanoidRootPart").CFrame = UsableSpawnPoints[1].CFrame + Vector3.new(0,8,0)
table.remove(UsableSpawnPoints,1)
local Sword = SS.Sword:Clone()
Sword.Parent = player.Backpack
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
else
if not player then
table.remove(PlayerTable,i)
end
end
end
end
Status.Value = "Get ready to Rumble?!!?!"
wait(2)
for i = 100,0,-1 do
for x, player in pairs(PlayerTable) do
if player then
local character = player.Character
if not character then
-- left the game
table.remove(PlayerTable,x)
else
if character:FindFirstChild("GameTag") then
-- They are still alive
print(player.Name.."is still in the game!!")
else
-- they are dead
table.remove(PlayerTable,x)
end
end
else
table.remove(PlayerTable,x)
print(player.Name.."has been removed!!")
end
end
Status.Value = "There are "..i.." seconds remaining, and "..#PlayerTable.." players left.."
if #PlayerTable == 1 then
Status.Value = "The winner is "..PlayerTable[1].Name
PlayerTable[1].leaderstats.Money.Value = PlayerTable[1].leaderstats.Money.Value + reward
break
elseif #PlayerTable == 0 then
Status.Value = "Nobody Won.."
break
elseif i == 0 then
Status.Value = "Time Up!"
break
end
print("End of Game!")
for i, player in pairs (game.Players:GetPlayers()) do
character = player.Character
if not character then
-- ignores them
else
if character:FindFirstChild("GameTag") then
character.GameTag:Destroy()
end
if player.Backpack:FindFirstChild("Sword") then
player.Backpack.Sword:Destroy()
end
if player.Backpack:FindFirstChild("Sword") then
character.Sword:Destroy()
end
end
MapSpawned:Destroy()
Status.Value = "The game has ended!"
end
wait(1)
end
end

3 comments
Are there any errors that show up?
No
Why does it say "money = game.Players.LocalPlayer". I think this is a server script so you should remove that line since it does nothing and and you can already do that without getting an error