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: Printing # of something?

Previous Thread :: Next Thread 
Madified is not online. Madified
Joined: 19 Apr 2011
Total Posts: 5292
28 Nov 2014 01:35 AM
I did something like this

for _, Players in pairs(game.Players:GetPlayers()) do
GWin = Players:FindFirstChild("PlayerIsIn")
print(#GWin)
end
Report Abuse
Madified is not online. Madified
Joined: 19 Apr 2011
Total Posts: 5292
28 Nov 2014 01:35 AM
That didnt work btw^
Report Abuse
ALGO160 is not online. ALGO160
Joined: 26 Mar 2012
Total Posts: 397
28 Nov 2014 02:02 AM
Invalid Syntax. I don't think there is a "#" operator in Lua.

I love Ruby, and LUA sucks. Let's replace Lua with ruby!
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
28 Nov 2014 02:07 AM
local function GetNumberOfPlayers()
return #game:GetService("Players"):GetPlayers
end

print(GetNumberOfPlayers())
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
28 Nov 2014 04:58 AM
print(#game.Players:GetPlayers())
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
28 Nov 2014 08:39 AM
ALGO, Lua does have #

local tab = {1, 2, "lol"}
print(#tab) -->3
local s = "Hello!"
print(#s) -->6


I think this is what OP wants

local function getPlayersIn(f)
local output = {}
for _, player in next, game.Players:GetPlayers() do
if player:FindFirstChild(f or "PlayerIsIn") then
table.insert(output, player)
end
end
return output
end

print(#getPlayersIn()) -->number of in players

also if you want players with say, a backpack
print(#getPlayersIn("Backpack")) -->number of players with a backpack
Report Abuse
Madified is not online. Madified
Joined: 19 Apr 2011
Total Posts: 5292
28 Nov 2014 01:15 PM
Thanks 128GB, you da real mvp
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