Hey all! I apologize if this question has been asked before, because I remember seeing it a while back (I never found it), but how would I detect all Players within a certain range? Now, I know your first response would be to make a while loop, then a for loop that goes through all players, and checks if they're near the part. That would be helpful, but I was wondering if there was an alternate way, possibly more efficient? I haven't attempted the script, because I do not know of a method that would accomplish this task. Any tips? Thanks all!
I would use DistanceFromCharacter()
or magnitude
. To see if all the players are in the place, I would use a loop. Or use Heartbeat or Renderstepped.
local part = workspace.Part local thing = 0 function activate() --Code goes here end game:GetService("RunService").RenderStepped:connect(function() for _,p in pairs(game:GetService("Players"):GetPlayers()) do if p:DistanceFromCharacter(part.Position) then thing = thing+1 if thing >= game:GetService("Players").NumPlayers then activate() end end end end)
This is the best I can think of... Anyway... Hope it helps!