How do I check player amount within zone?

I’m using ZonePlus for this, and I’m curious how I can count the amount of players in the zone. local playersArray = joinZone:getPlayers() simply returns a table. I tried doing

local playersArray = joinZone:getPlayers()

but it printed 0, even though one person was in the area.
How am I supposed to do this?

Depending on how they were added to the table the # wouldn’t work. What you could do is loop through the table like this:

local playerCount = 0
for Index, Value in pairs(joinZone:GetPlayers()) do
   if Value then
      playerCount += 1 
1 Like

This works perfectly, thank you so much!

1 Like

You dont need to use ZonePlus anymore as roblox recently added this:
Introducing OverlapParams - New Spatial Query API

that would most likely be more efficient

1 Like