Making a minigame game. The players walk into the room to be in the game, how do I check what players are in that specific area?
Hi there!
ProgrammerColton here.
There is various ways that you can accomplish this which can be found in the following statements:
1) Magnitude - Using magnitude, you can check if the player is within the range of a certain block.
wiki post can be found here
2) .Touched - Using a touched event, you can check if the player currently touching a brick that is within a certain sector (or area). Such as, if the players walk into a room, add an invisible block in the door frame and when they touch it, add them to a list of current players that are willing to play the minigame.
wiki post can be found here
3) Raycast - Using a raycast, you could shoot a raycast upwards and detect if the player walks under a certain block thats above the specific area that you are talking about.
wiki post can be found here
Best Regards,
make a part in your building the size of the inside but make sure the part is a square then make its transparency 1 then add this script in the workspace or server script service
local plrs = {} function CreateRegion3FromPart(Part) return Region3.new(Part.Position-(Part.Size/2), Part.Position + (Part.Size/2)) end function GetPlayersInRegion(Part) local region = CreateRegion3FromPart(Part) local plrfound = false local InRegion = workspace:FindPartsInRegion3(region,nil,math.huge)--math.Huge is the player limit for example if i want a max 5 people change math.huge to 5 for i,v in pairs(plrs) do -- clearing all the players in the table so if a player leaves the area the script dosent run for them table.remove(plrs, i) end for i, part in pairs(InRegion) do -- part is like a leg or arm local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then for i,v in pairs(plrs) do if plrs[i] == plr.Name then plrfound = true end end if plrfound == false then table.insert(plrs, plr.Name) end plrfound = false-- resetting value for next player end end end while true do wait() GetPlayersInRegion(workspace.Example) --change workspace.Example to your part for i,v in pairs(plrs) do wait()-- nessary or theres alot of lag if plrs then print(plrs[i]) -- do what ever you want like kill them or just print their name end end end