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

Why is my table not inserting values?

Asked by 3 years ago
revealVotes.Event:Connect(function()
    local mapVotes = {}
    local playerVotes = {}

    for i, map in pairs(game.ReplicatedStorage.VotedMap:GetChildren()) do
        table.insert(mapVotes, map.Value)
        wait()
    end
    for i, choice in pairs(game.ReplicatedStorage.VotedPlayers:GetChildren()) do
        table.insert(playerVotes, choice.Value)
        wait()
    end

    table.sort(mapVotes)
    table.sort(playerVotes)
    local mapWinner = tonumber(mapVotes[#mapVotes])
    local playerWinner = tonumber(playerVotes[#playerVotes])
    print(unpack(mapVotes))
    print(unpack(playerVotes))

    for i, map in pairs(game.ReplicatedStorage.VotedMap:GetChildren()) do
        if map.Value == mapWinner then
            winnerMap.Value = map.Name
        end
    end
    for i, choice in pairs(game.ReplicatedStorage.VotedPlayers:GetChildren()) do
        if choice.Value == playerWinner then
            winnerPlayers.Value = choice.Name
        end
    end

end)


https://scriptinghelpers.org/questions/118136/why-is-my-table-not-inserting-any-values (Repost. I suspect that the problem is with the for loops not adding any values. Any ideas?)

Answer this question