JamSnack
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 154 |
|
|
| 06 Aug 2017 08:39 PM |
This chunk of code does not have an error, I just needed to know how I would add a check to it so it checks if there are no more players left alive. #_G.gameplayers contains how many players are still alive, if 1 is still alive they are rewarded Zelch. If two players are fighting and they both kill each other the timer ticks down until the match is over.
if #_G.gameplayers == 1 then for i, v in pairs(_G.gameplayers) do if v ~= nil then status.Value = v.." remains" game.Players[v].leaderstats.Zelch.Value = game.Players[v].leaderstats.Zelch.Value + 10 break end end break else status.Value = i.." seconds remain" end end
I expect the code to be something like if v == nil then status.Value = "Noone remains."
|
|
|
| Report Abuse |
|
|
Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
|
| 06 Aug 2017 08:41 PM |
| if #game.Players:GetPlayers() == 0 |
|
|
| Report Abuse |
|
|
Sur4y
|
  |
| Joined: 05 Jul 2013 |
| Total Posts: 5669 |
|
|
| 06 Aug 2017 08:43 PM |
elseif #_G.gameplayers == 0 then
ᕕ( ᐛ )ᕗ / @Sur0100y / Every good thing has an ending. [RT] |
|
|
| Report Abuse |
|
|
Vultorz
|
  |
| Joined: 02 Mar 2015 |
| Total Posts: 2985 |
|
| |
|
JamSnack
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 154 |
|
|
| 06 Aug 2017 08:45 PM |
| Time to spend the next hour trying to kill myself and a clone of the roblox simulation before it calculates that 1 player is still alive. - ;P; |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2017 08:48 PM |
| Your going off AlvinBlox's games videos. And how I know is the code(Photographic Memory)! _G is mostly used globally. How he approached it made more sense than you do. I would help you but i don't really know what you are trying to achieve. Sorry! |
|
|
| Report Abuse |
|
|
JamSnack
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 154 |
|
|
| 06 Aug 2017 08:51 PM |
| Yeah I am new to LUA so I am reverse engineering things and have surprisingly made a ton of stuff on my own from that one tutorial. Basically if there are two players when a round is still going on and they kill each other in the same second, the code checks if 1 of them are still alive. If none are alive it then the number is 0 and it counts down checking to see if 1 person is alive. |
|
|
| Report Abuse |
|
|
JamSnack
|
  |
| Joined: 04 Aug 2011 |
| Total Posts: 154 |
|
| |
|