I have been working with a round system for my new game and it does not seem to be working. Please help!
local status = game.ReplicatedStorage.Status
local maps = game.ReplicatedStorage.maps:GetChildren()
while true do
for i = 1,10 do
status.Value = "Intermission "..10-i
wait(1)
end
local rand = math.random(1, #maps)
local map = maps[rand]:Clone()
map.Parent = workspace
status.Value = "Selected Map: "..map.Name
wait(4)
local players = game.Players:GetChildren()
for i = 1,#players do
if players[i].Character ~= nil then
local spawnLocation = math.random(1,#workspace.Teleports:GetChildren())
players[i].Character:MoveTo(workspace.Teleports:GetChildren()[spawnLocation].Position)
players[i].Character.Parent = workspace.Ingame
end
end
local roundLength = 50
local canWin = true
local roundType = ""
if map:FindFirstChild("Volcano") or ("Forest")then
roundType = "Fight"
local children = workspce.Ingame:GetChildren()
for i = 1,#children do
map:FindFirstChildWhichIsA("Tool)"):Clone().Parent = children[i]
end
map:FindFirstChildWhichIsA("Tool"):Destroy()
end
repeat
roundLength = roundLength = 1
status.Value = "time left "..roundLength
wait(1)
until roundLength == 0 or canWin == false or #workspace.Ingame=GetChildren(#workspace.Ingame=GetChildren() == 1 and roundType == "Fight")
if #workspace.Ingame:GetChildren() == 1 and roundType == "Fight" then
satus.Value == workspace.Ingame:FindFirstChildWhichIsA("Model"):Name.." has won!"
end
wait(3)
map:Destroy()
local players = game.players:GetChildren()
for i = 1, #players do
if players[i].Character ~= nil then
players[i]:LoadCharacter()
end
end
end