There are two ways you can do this.
#Region3
A Region3 is a section of the world, a representation of location and size of a 3D area from one corner to its opposite corner. To create a Region3 from a part, you can use this formula position - (size/2), position + (size/2).
local tpPart = game.Workspace.gameTeleport
local partRegion = Region3.new(tpPart.Position - (tpPart.Size/2), tpPart.Position + (tp.Size/2))
The Workspace has a FindPartsInRegion3 method (and a variety of similar ones, such as with ignore lists) which will return an array of the parts inside a region.
local function teleportToGame()
local partsInRegion = game.Workspace:FindPartsInRegion3(partRegion, nil, math.huge)
for _, part in ipairs(partsInRegion) do
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
end
end
end
#Part:GetTouchingParts()
This next method will be similar to Region3, but you can do it directly from your part. It returns an array of the parts touching it. Note that parts with collisions disabled, they will not count as a touching part.
local function teleportToGame()
local touchingParts = game.Workspace.gameTeleport:GetTouchingParts()
for _, part in ipairs(touchingParts) do
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player then
end
end
end
And that seems to be it. I'd suggest using Region3 because you can still capture parts even with collisions disabled, but it shouldn't be a problem to use :GetTouchingParts() if the players are able to touch the part with their head or torso, since the legs and arms have collisions disabled.
######Hopefully this answered your question, and if it did, then don't forget to hit that "Accept Answer" button. If you have any other questions, then feel free to leave them down in the comments.
1 comment
The Region3 seems to work. Thanks a lot! if you want you can see what im using this for in. (a crude flood escape parody game) https://www.roblox.com/games/2647365119/poop-escape-crude-parody-of-flood-escape