How do I make for loop count all table value?

I’m trying to make a list that shows how many players are online on all servers.

My problem is that it only picks one server to count, so I made a for loop that loops through all server player count. But now it picks the one with the lowest players.

I’m new to all of this stuff so I’m having a hard time trying to solve this, A solution would be very appreciated.

for i,v in pairs(data) do
  wait(0.1)

  local alldata = data[0 + i]["playing"]
  script.Parent.Text = tostring(alldata) .. " Players Online"
end
local total = 0 --starting from 0
for i, server in pairs(data) do
	task.wait(0.1)
	--data[i] is equal to the current value(server)
	--value1 += value2 is value1 = value1+value2
	total += server["playing"]
end
--tostring isn't needed
script.Parent.Text = total.." Players Online"
1 Like

Here is a good example: How do I get the amount of players playing my game? - #11 by GEILER123456

It requires you to communicate with all of the servers, you can also use HTTPService for this. (not sure if i understood you but i think so)

1 Like