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

How do I use this script to display who won the minigame?

Asked by 10 years ago

I need it to display who won the minigame; and/or who is still alive. I'm also trying to make it so it would award the winner(s) 10 points.

msg.Parent = game.Workspace
msg.Text = "Winner(s)!"
0
The way I made my script is that, after 120 seconds, it displays the script above. But it doesn't display the players who won. I dont know how to make it so that it will. MUSHR0OM 0 — 10y

1 answer

Log in to vote
1
Answered by
Dummiez 360 Moderation Voter
10 years ago

If you have a leaderboard script, where there is a value called 'Alive' or 'Winners' then you can do this.

-- List the players who are still alive and add them onto the winner's list.

local p = game.Players:GetPlayers()
local winners = {}

for i = 1, #p do 
    if p[i].leaderstats["Alive"].Value then
        print(p[i].Name.. ' is alive!')
        table.insert(winners, p[i].Name)
    end
end

Displaying the winner message.

-- Should be in the same script to get the winners.

local msg = "Winners are"

for j = 1, #winners do 
msg = (msg..", " ..winners[j])
end

local gm = Instance.new("Message")
gm.Parent = Workspace
gm.Text = msg
wait(5)
gm:Destroy()
Ad

Answer this question