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

Display Shows 0 Points after Game Finishes?

Asked by 6 years ago

Basically I have this MVP script that gets the players with the most points from a Player, and after every game, it shows the player's name, but everyone has 0 points.

The image will show you what I mean. Here are the scripts.

Choosing Players

function TopPlayers(team)
    local winners = {}
    local board = {}
    for _,v in next,team:GetPlayers() do
        local Points = v:WaitForChild("Points")
        board[#board + 1] = {v,v.Points.Value}
    end
    table.sort(board, function(a,b) return a[2] > b[2] end)
    local highest = board[#board][2]
    for _,v in next,board do
        if v[2] == highest then
            winners[#winners + 1] = v[1].Name
        end
    end
    return winners,highest
end

Display

function EndRound()
local redWinners, redHighest = TopPlayers(game.Teams["CLE Cavaliers"])
local blueWinners, blueHighest = TopPlayers(game.Teams["GS Warriors"])
for _,v in next,game.Players:GetPlayers() do
    local Points = v:WaitForChild("Points")
    v.Points.Value = 0
end
wait(1)
    display.Value = "Cavaliers MVP(s): "..table.concat(redWinners," , ").." with "..redHighest.." points!"
wait(5)
    display.Value = "Warriors MVP(s): "..table.concat(blueWinners," , ").." with "..blueHighest.." points!"
wait(5)
    display.Value = ""
end

Image

-LukeGabrieI

Answer this question