generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Wait until 1 player left

Previous Thread :: Next Thread 
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
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 is not online. 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
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
05 Nov 2014 11:36 AM
I sound like an idiot here, but what code shall I put in the function?
Report Abuse
128GB is not online. 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
DeveloperAlvin is not online. DeveloperAlvin
Joined: 22 Feb 2011
Total Posts: 894
05 Nov 2014 12:43 PM
No no no. I mean like the last man standing.
Report Abuse
xXFIREFACEXx is not online. xXFIREFACEXx
Joined: 18 Jul 2012
Total Posts: 1427
05 Nov 2014 01:31 PM
Last man standing? The code he just wrote you is just that...
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image