I'm making a pad that can count how many people are standing on it. It also shown on the screen. Thx!
Some example lines:
p = #game.Players:GetPlayers() print(p) -- Or display it in a GUI
Try using FindPartsInRegion3WithWhiteList
local Players = game:GetService("Players") local Workspace = game:GetService("Workspace") local Region = Region3.new(Vector3.new(-100, -100, -100), Vector3.new(100, 100, 100)) local CharacterHeads = {} local function PlayerAdded(Player) local Index local function CharacterAdded(Character) local Head = Character:FindFirstChild("Head") if Head then Index = #CharacterHeads + 1 CharacterHeads[Index] = Head end end CharacterAdded(Player.Character) Player.CharacterAdded:Connect(CharacterAdded) Player.CharacterRemoving:Connect(function() table.remove(Index) end) end local Playerlist = Players:GetPlayers() for i = 1, #Playerlist do PlayerAdded(Playerlist[i]) end local function GetPlayersWithinRegion3(Region3ToSearch) local Playerlist = Workspace:FindPartsInRegion3WithWhiteList(Region3ToSearch, CharacterHeads, #CharacterHeads) for i = 1, #Playerlist do Playerlist[i] = Players:GetPlayerFromCharacter(Playerlist[i].Parent) end return Playerlist end table.foreach(GetPlayersWithinRegion3(Region), print)
Closed as Not Constructive by BlackOrange3343, DeceptiveCaster, and hellmatic
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?