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: Detect

Previous Thread :: Next Thread 
peIicans is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. peIicans
Joined: 02 Nov 2013
Total Posts: 1148
27 May 2016 08:47 PM
how would i do that


Report Abuse
doctor152 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. peIicans
Joined: 02 Nov 2013
Total Posts: 1148
27 May 2016 09:04 PM
b1


Report Abuse
peIicans is not online. peIicans
Joined: 02 Nov 2013
Total Posts: 1148
27 May 2016 09:10 PM
b2


Report Abuse
peIicans is not online. peIicans
Joined: 02 Nov 2013
Total Posts: 1148
27 May 2016 09:55 PM
b3


Report Abuse
zaniac10 is not online. 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
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