Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script runs through once only?

Asked by 9 years ago

Hi guys, I have made the following round script that should start a new round but only goes through once.. I don't know why.Round duration always 5 minutes. Here is a list of things that shouldn't happen (but do):

  • Players spawn outside the lobby . Spawns located in the lobby are set to the "Not Playing" TeamColor and do not change
  • The script stops after one round, even with 5 players staying in the server

Any suggestions?

--[[        NOTE

The following functions are working properly and will not be posted in order to reduce the size of the faulty code: ChooseMap() GetPlayersInTeam(Team) ChooseTeam() CloneKnives(knives,player) ChooseRound()

]]

function Classic()
    classic = true
    workspace.Ingame.Value = true
    Text = "Round Chosen: Classic"
    for i=1,#Text do
        game.Workspace.Lobby.Noti.SurfaceGui.TextLabel.Round.Text = Text:sub(1,i)
        wait(0.1)
    end
    ChooseMap()
    Map = "Map Chosen: "..chosen.Name
    for i=1,#Map do
        game.Workspace.Lobby.Noti.SurfaceGui.TextLabel.Map.Text = Map:sub(1,i)
        wait(0.1)
    end
    chosen.Name = "Map"
    ChooseTeam()
    players = game.Players:GetPlayers()
    for i=1,#players do
        players[i]:LoadCharacter()
        knives = game.Lighting.Knives
        CloneKnives(knives,players[i])
    end
    chosen.During:Play()
    game.Workspace.Time.Value = 5*60
    game.Players.PlayerAdded:connect(function(player)
        if game.Workspace.Time.Value >10 and classic then
        player.TeamColor = game.Teams.Playing.TeamColor
        wait(0.5)
        player:LoadCharacter() end  
        CloneKnives(knives,player)  
    end)
    while wait()  do
        players = game.Players:GetPlayers()
        if game.Workspace.Time.Value == 0 or game.Players.NumPlayers <=4 then
            workspace.Ingame.Value = false
            for i=1,#players do
                if game.Players:FindFirstChild(players[i]) then
                items = players[i].Backpack:GetChildren()
                for b = 1,#items do
                    if items[b]:IsA("Tool") then
                        items[b]:Destroy()
                    end
                end
                tools = players[i].StarterGear:GetChildren()
                for v=1,#tools do
                    tools[v]:Destroy()
                end
                players[i].TeamColor = game.Teams["Not Playing"].TeamColor
                wait(0.5)
                players[i]:LoadCharacter() end
            end
            chosen.During:Stop()
            game.Workspace:FindFirstChild("Map"):Destroy()
            break
        end
    end 
    game.Workspace.Time.Value = 0
    players = game.Players:GetPlayers()
    for i = 1,#players do
        if players[i] then
        players[i].TeamColor = game.Teams['Not Playing'].TeamColor
        players[i]:LoadCharacter()end
    end
    workspace.End:Play()
    wait(6)
    while wait() do
        if workspace.End.IsPlaying == false then
            break
        end
    end
    classic = false
end

while true do
    wait(5)
        a = game.Workspace.Time.Tme
        if game.Players.NumPlayers == 3 then
            Text = "Waiting for 1 more player"
            for i=1,#Text do
                a.Value = Text:sub(1,i)
                wait(0.1)
            end
        elseif game.Players.NumPlayers >3 then ChooseRound()
        else 
            Text = "Waiting for "..(4-game.Players.NumPlayers).." More Players"
            for i=1,#Text do
                a.Value = Text:sub(1,i)
                wait(0.1)
            end 
        end
        wait(1.9)
        a.Value = ""
end

Answer this question