How do I get a player from a zone?

If you are using an invisible/non-collide brick to define your region, here is a function that can determine if a given Vector3 position is inside of it:

function isInsideBrick(position, brick)
	local v3 = brick.CFrame:PointToObjectSpace(position)
	return (math.abs(v3.X) <= brick.Size.X / 2)
		and (math.abs(v3.Y) <= brick.Size.Y / 2)
		and (math.abs(v3.Z) <= brick.Size.Z / 2)
end

This should work regardless of the hitbox’s rotation.

44 Likes