sentanos / roblox-js

!!!THIS PROJECT IS NO LONGER MAINTAINED!!! Execute ROBLOX website actions in node.js
MIT License
45 stars 45 forks source link

Roblox - GetPlayers function #21

Closed ConfidentCoding1 closed 7 years ago

ConfidentCoding1 commented 7 years ago

screenshot_1686

I am trying to call the GetPlayers function from Roblox Studio.

However every time I call the function the returned table always as 0 entries/arrays in it.

sentanos commented 7 years ago

First of all the players are contained in the data.players field of the table. Second, even if you tried to get the length of this it would not work because it is a dictionary and you cannot get the length of those using #. Here is what you would do to get the number of players returned:

local function count (t)
  local sum = 0
  for i in next, t do
    sum = sum + 1
  end
  return sum
end

local players = api.getPlayers(6, 4, false).data.players
print(count(players))
ConfidentCoding1 commented 7 years ago

Thank You!