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 » Scripters
Home Search
 

Re: Script help

Previous Thread :: Next Thread 
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
04 Aug 2016 11:21 PM
I'm lost on how I would end a game if all players die. I know have I have to make a table, but I'm still confused.


Report Abuse
Laedere is not online. Laedere
Joined: 17 Jun 2013
Total Posts: 23601
04 Aug 2016 11:22 PM
after a person dies store their name in the table
if the table length is equal to the amount of players in the game then everyone is dead


Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
04 Aug 2016 11:24 PM
Im new to scripting, still confused.


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
04 Aug 2016 11:24 PM
^ Make sure that if they die twice (assuming that's possible) you don't add their name twice.


Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
04 Aug 2016 11:26 PM
hmm so how would I actually script if they die? and what if someone joins in the middle of the round and resets.


Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
04 Aug 2016 11:27 PM
Well the humanoid has an event called Died which fires whenever that humanoid dies. You'll want to make a table of all the players in the game using the GetPlayers method, then when one of them dies remove them from the table until nobody remains. Here's just a small example of what you're looking for:

local myPlayers = game.Players:GetPlayers() --set myPlayers to a table of all players

for i,v in pairs(myPlayers) do --for each player
if v.Character then --if they have a character (just in case)
v.Character.Humanoid.Died:connect(function() -- when they die
table.remove(myPlayers, i) --remove them from the table
if #myPlayers == 0 then --if there are no more players then
print'THEYRE ALL DEAD!'
end
end)
end
end
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
04 Aug 2016 11:28 PM
Having a table at the start and removing them is better because it doesn't get messed up by people that join halfway through, it entirely ignores them. If you want to add people who join you'll have to use some other method.
Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
04 Aug 2016 11:30 PM
Thanks so much I appreciate it. I want it to ignore people who join, so thats good.


Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
04 Aug 2016 11:30 PM
Also, so I need to script is the actual game ending? which shouldn't be too hard.



Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
04 Aug 2016 11:38 PM
yeah where I print 'THEYRE ALL DEAD' just put what you want to happen when all players are dead. Keep in mind I haven't tested the script so they're could be errors I just overlooked.
Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
04 Aug 2016 11:38 PM
Hmm let's say someone was in the round playing ,then decide to leave. Then all players die besides one. Wouldn't the game reset then? How would I fix this glitch,


Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
04 Aug 2016 11:41 PM
This will go after the other stuff, just removes them from the table if they leave.

game.Players.PlayerRemoving:connect(function(p)
for i,v in pairs(myPlayers) do
if v == p then
table.remove(myPlayers, i)
if #myPlayers == 0 then
print'oops the last player left'
end
end
end
end)
Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
04 Aug 2016 11:59 PM
Thanks!!


Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
05 Aug 2016 12:23 AM
hmm I tested it and it doesnt reset if theres two players. only one.


Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
05 Aug 2016 12:23 AM
What's your script. Mine should only be used when you want the game to start.
Report Abuse
Kungkupanada is not online. Kungkupanada
Joined: 15 Nov 2010
Total Posts: 11
05 Aug 2016 12:25 AM
I put it before the players spawn in the map. hm


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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