|
| 05 Nov 2014 11:32 AM |
Hey, I have an elimination round in my game and wondered, how would you instantly keep checking if there's one player left and display that player's name in a GUI?
Alvin |
|
|
| Report Abuse |
|
|
ByDefault
|
  |
| Joined: 25 Jul 2014 |
| Total Posts: 3197 |
|
|
| 05 Nov 2014 11:34 AM |
function checkifplrsleft() if there is one player left in the round then he wins and gets 100 points, everybody else loses. end |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2014 11:36 AM |
I sound like an idiot here, but what code shall I put in the function?
|
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 05 Nov 2014 11:45 AM |
I would do something like this no idea if this works but yah
local players = {}
game.Players.PlayerRemoving:connect(function(player) for index, playerName in pairs(players) do if player.Name == playerName then table.remove(players, index) return end end)
for _, player in pairs(game.Players:getPlayers()) do if player.Character and player.Character:findFirstChild("Humanoid") then table.insert(players, player.Name) player.Character.Humanoid.Died:connect(function() for index, playerName in pairs(players) do if player.Name == playerName table.remove(players, index) return end end end) end end
while #players > 1 do wait() end
local winner = (players[1] and players[1] or "no one") print("The winner is " .. winner)
Something like that |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2014 12:43 PM |
| No no no. I mean like the last man standing. |
|
|
| Report Abuse |
|
|
|
| 05 Nov 2014 01:31 PM |
| Last man standing? The code he just wrote you is just that... |
|
|
| Report Abuse |
|
|