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

Why does GameTag only gets assigned to one of the characters? (Player1 instead of player2 only)

Asked by 4 years ago

I have a script here that has a game tag that is only parented to one character in a test server of 2 characters. Here is it:

local plrs = {}

    for i, player in pairs(game.Players:GetPlayers()) do
        if player then
            table.insert(plrs,player)
        end

        status.Value = "Preparing..."
        wait(3)

        local rand = math.random(1, #maps)

        local map = maps[rand]:Clone()
        map.Parent = workspace

        status.Value = "Map Chosen: " .. map.Name
        wait(3)

        local spawns = map:FindFirstChild("Spawns")

        if not spawns then
            print("Spawns not found")
        end

        local availablespawns = spawns:GetChildren()

        for v, playr in pairs(plrs) do

            if playr ~= nil then
                print(playr)
                character = playr.Character

                if character then
                    character:FindFirstChild("HumanoidRootPart").CFrame = availablespawns[1].CFrame
                    table.remove(availablespawns,1)
                    local GameTag = Instance.new("BoolValue")
                    GameTag.Name = "GameTag"
                    GameTag.Parent = character

Answer this question