peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
|
| 27 May 2016 08:34 PM |
how to detect how many players there are left through a bool value
like if there is 6 people left(their value is true), they will be teleported. and how to teleport those specific 6 people.
|
|
|
| Report Abuse |
|
|
doctor152
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 308 |
|
|
| 27 May 2016 08:37 PM |
Assuming the bool value is in the player and is called "Alive", then this:
for i,v in pairs(game.Players:GetChildren()) do if v:FindFirstChild("Alive") and v.Alive.Value == true then v.Character.Torso.CFrame = CFrame.new(Vector3 coords of teleport) -- Using setprimarypartcframe is unnecessary end end
|
|
|
| Report Abuse |
|
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
|
| 27 May 2016 08:39 PM |
is there a way to do that if there is 6 people left only
|
|
|
| Report Abuse |
|
|
doctor152
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 308 |
|
|
| 27 May 2016 08:40 PM |
Well that would pick up every alive player so restricting the server to 6 would do exactly that. It would seem rather pointless to check 6 when you can check them all.
|
|
|
| Report Abuse |
|
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
|
| 27 May 2016 08:42 PM |
but it's a 25 player server and when 6 people are alive, they're teleported to a specific spot to fight each other.
|
|
|
| Report Abuse |
|
|
doctor152
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 308 |
|
|
| 27 May 2016 08:43 PM |
Assuming you have all the players in a table, just use a for loop through the table and check the values inside each.
|
|
|
| Report Abuse |
|
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
| |
|
doctor152
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 308 |
|
|
| 27 May 2016 08:49 PM |
Let's say you have the players in a table like so:
local plrs = {plr1,plr2,plr3,plr4,plr5,plr6}
You can cycle through them using a for loop:
for i=1, #plrs do if plrs[i]:FindFirstChild("Alive") and plrs[i].Value==true then plrs[i].Character.Torso.CFrame = CFrame.new(Vector3 Value) end end
|
|
|
| Report Abuse |
|
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
|
| 27 May 2016 08:52 PM |
i'd put specific names in the table??
|
|
|
| Report Abuse |
|
|
doctor152
|
  |
| Joined: 30 Nov 2008 |
| Total Posts: 308 |
|
|
| 27 May 2016 08:55 PM |
You'd put the player objects in the table. I suggest looking more into ROBLOX Lua before continuing your project.
|
|
|
| Report Abuse |
|
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
|
| 27 May 2016 08:57 PM |
I have everything else, I just need a little help on this one part.
|
|
|
| Report Abuse |
|
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
| |
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
| |
|
peIicans
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 1148 |
|
| |
|
zaniac10
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 10000 |
|
|
| 27 May 2016 10:29 PM |
local plrs = {} amount = 0
for _,v in next, game.Players:GetChildren() do if v:IsA("Player") then local alive = v:WaitForChild("Alive") if alive.Value == true then table.insert(plrs, v) end end end
game.Players.Changed:connect(function() for _,v in next, plrs do amount = amount + 1 end if amount == 6 then amount = 0 for _,v in next, game.Players:GetChildren() do if v:IsA("Player") then v.Character.Torso.CFrame = part.CFrame end end end end)
|
|
|
| Report Abuse |
|
|