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

Player's Name Won't Show After Game? [MVP-Type Script]

Asked by 6 years ago
Edited 6 years ago

So after every game, the person with the most points will be announced in a message or like a display, for some reason, it won't pop up. Here are the scripts.

First, I have a script where it'll get the player with the most points from both teams.

for i,v in pairs(game.Players:GetPlayers()) do
    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] = v[1]
        end
    end
    return winners,highest
    end
end

Then, I have the message script, where it gets the player's name and their points. The thing is it'll only show their points, but not their name.

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
    display.Value = "Cavaliers MVP(s): "..table.concat(redWinners,", ").." with "..redHighest.." points!" -- the part at table.concat is where it doesn't work or show up.
    wait(3)
    display.Value = "Warriors MVP(s): "..table.concat(blueWinners,", ").." with "..blueHighest.." points!"
    wait(3)
    display.Value = ""
end

It could be because it's at the beginning of the script? Or maybe, I don't know. But regardless, it does work, but it just won't show the player's name.

-LukeGabrieI

Answer this question