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

Why are some of these codes not working?

Asked by 9 years ago

I have a game, which uses rounds of 5 mins each. Currently, I'm setting up a Deathmatch Round. Here are my Problems:

When the round starts, only 1 player gets teleported to the map When a player joins during rounds, his team is set, but his tools won't come neither will he teleport When a person dies, he either spawns in the lobby or on the map. In addition, his tools won't come - back

function ChooseTeam()
    Players = game.Players:GetPlayers()
    for i = 1,#Players do
        Players[i].TeamColor = game.Teams.Playing.TeamColor
    end
end
function ChooseMap()
    Maps = game.Lighting.Maps:GetChildren()
    chosen = Maps[math.random(1,#Maps)]:Clone()
    chosen.Parent = game.Workspace
end
function Classic()
    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
    game.Workspace:WaitForChild(chosen.Name).Name = "Map"
    ChooseTeam()
    players = game.Players:GetPlayers()
    for i=1,#players do
        players[i]:LoadCharacter()
        game.Lighting.Starter:Clone().Parent = players[i].Backpack
    end
    game.Workspace.Time.Value = 5*60
    game.Players.PlayerAdded:connect(function(player)
        if game.Workspace.Time >10 then
        player.TeamColor = game.Teams.Playing.TeamColor
        a = game.Lighting.Starter:Clone()
        player:WaitForChild("Backpack")
        a.Parent = player.Backpack
        wait(0.5)
        player:LoadCharacter() end      
    end)
    game.Players.PlayerRemoving:connect(function(player)
        if game.Players.NumPlayers < 2 then
            Players = game.Players:GetPlayers()
            for i = 1,#Players do
                Players[i].TeamColor = game.Teams["Not Playing"].TeamColor
                Tools = Players[i].Backpack:GetChildren()
                for w=1,#Tools do
                    if Tools[w]:IsA("Tool") then
                        Tools[w]:Destroy()
                    end
                end
                wait(0.5)
                Players[i]:LoadCharacter()
            end
            game.Workspace.Time.Value = 0
            game.Workspace:WaitForChild("Map"):Destroy()
        end 
    end)
    while wait() do
        if game.Workspace.Time.Value == 0 then
            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
                players[i].TeamColor = game.Teams["Not Playing"].TeamColor
                wait(0.5)
                players[i]:LoadCharacter() end
            end
            game.Workspace:FindFirstChild("Map"):Destroy()
            break
        end
    end 
end
function ChooseRound()
    Round = {"Classic"}
    Rchosen = math.random(1,#Round)
    if Rchosen == 1 and game.Players.NumPlayers >= 2 then Classic()
    end
end
while wait(10) do
    if game.Players.NumPlayers >= 2 then
        ChooseRound()
    end
end

Could someone please help me out?

P.S: If you would like to be credited on the game, please tell me.

1
Script is too long. EzraNehemiah_TF2 3552 — 9y
0
I couldn't figure out which part is wrong... Sorry for that. fahmisack123 385 — 9y

Answer this question